I'm trying to catalog a bunch of files on OSX using ruby, essentially doing this:
hash = Digest::SHA1.hexdigest(File.open(fullpath).read)
This is failing on filenames that contain apostroph开发者_如何学编程es, which are legal characters for a filename.
The File.open works, but I get an "Errno::EINVAL: Invalid argument" error from the read. The filenames are coming directly out of a Dir[] glob.
I've tried escaping them with backslashes, but that doesn't seem to work.
What's the right way to escape these filenames?
精彩评论