[Win32utils-devel] win32-file-stat and unc directory paths

Heesob Park phasis at gmail.com
Sat Apr 13 12:48:32 UTC 2013


Hi,

2013/4/13 Daniel Berger <djberg96 at gmail.com>:
> Hi everyone,
>
> As I'm converting win32-file-stat to use FFI, I've run into an issue where I
> can't seem to successfully call CreateFile on a UNC directory path. It works
> fine if I call it on a file, but not on the directory itself.
>
> Using my own local network, this works:
>
> # inside stat.rb
> File::Stat.new("//myhost/users/djberge/documents/foo.txt")
>
> But this does not:
>
> File::Stat.new("//myhost/users")
>
> Which is strange, because in a separate, standalone program it works fine,
> but I can't see what the difference is. I need a second pair of eyes,
> please. The code is in git.
>
In my test, the latter case files in FindFirstFile instead of CreateFile:
The network name cannot be found. - FindFirstFile (SystemCallError)

I can see following statement in the msdn documentation of FindFirst:
On network shares, you can use an lpFileName in the form of the
following: "\\Server\Share\*". However, you cannot use an lpFileName
that points to the share itself; for example, "\\Server\Share" is not
valid.

I guess you will succeeds in case of File::Stat.new("//myhost/users/djberge").

Regards,
Park Heesob


More information about the win32utils-devel mailing list