Ruby Dir.glob on windows network share

dir, glob, ruby, windows

Solution

Here a working sample on Windows7 and Ruby 1.9.3

def get_files(path)
  Dir.glob("#{path}/**/*").each {|e|puts e}
end

list_files("//USER-PC/SHARE/MAP")

Problem

I would like to get a simple list of files with Dir.glob on a windows machine, where the filter would be something like `//hostname/share/folder/*.zip`. The only thing that works with glob on windows is a local path: `c:/folder/*.zip` I tried different ways, but no luck so far: ``` \\\\hostname\\share\\folder\\*.zip \\hostname\share\folder\*.zip //hostname/share/folder/*.zip z:/folder/*.zip # z: would be a network drive ``` I'm using Ruby 1.8.7-p352 and tried on different windows platforms.

Original source