Question

I'm using RubyZip to access the files inside of a Zip directory.

Zip::ZipFile.open(self.package.to_s) do |zipfile|
    zipfile.glob("**/*.*").each {|file| update_or_save(file)}
end

RubyZip has a similar #glob method to Ruby Dir#glob. From my understanding of this method,

.glob("**/*.*")

Should be creating an array of all files in the subdirectories within the Zip folder. This works great for the mot part but I'm now running into an error, where a directory seems to be getting included in the array.

test dvd/02 Vision Seminars and TOTs/1 TOT I/TOT I Handouts/Hungary Dr. Anna handouts/

Why is a directory being included here? I will likely add a rescue here if need be, but I'm confused to why this directory is being added in the first place.

Était-ce utile?

La solution

That directory name matches the pattern you supplied to the #glob method. The pattern simply looks for a file or directory name that contains a . character at any level of the zip file.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top