-
Notifications
You must be signed in to change notification settings - Fork 1.1k
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unix.stat behaves differently on win32 and linux #5429
Comments
Comment author: @gasche I'm not sure I understand why this is a bug. "somedir/" is a legal path on Unix (which is generally lenient regarding trailing directory separators), while it does not on Windows. I don't see what other behavior you could hope with this. If you want your code to be robust, you must not use hardcoded separators but Filename.concat or Filename.dir_sep: Could you be more explicit in what behavior you expect? |
Comment author: ripoche I think it depends of the intended goal of the Unix library. If it is to stay as close to unix semantics as possible, then it should be fixed. In the light of all the work done to correctly handle file, pipes and sockets on Windows, it seems to me that unix semantics is the goal, hence this bug. As a side note, ruby 1.8.2 handles this case gracefully. |
Comment author: ripoche Also, I stumbled upon this while porting some OCaml software on win32/msvc. Had it been in my code, I would have worked around it. |
Comment author: ripoche Python 2.7.2 also handles this case gracefully. |
Comment author: @protz It's the usual discussion: as you start implementing workarounds like this, you become part of the problem, and not part of the solution. Encouraging people to write unix paths with the expectation that it will work out-of-the-box on Win32 is, imho, not a good thing. What kind of solution do you suggest? Parsing a path as a unix-one under windows just to remove the trailing slash sounds like quite the hack... |
Comment author: ripoche Regarding portability between win32 and posix, I'm sure most would agree that python, and to a lesser extent ruby, do a decent job. They do work around the issue, simply because in their eyes it makes sense as "systems programming languages" (whatever that means). If they didn't then they would have the same issues we face now. I glanced at their sources and here is how they do it:
|
Comment author: ripoche It certainly is more complicated than I originally thought... |
Comment author: @damiendoligez I find @protz's argument convincing, and I don't think we want to reimplement the C runtime (or standard library) like python and ruby do. |
Original bug ID: 5429
Reporter: ripoche
Status: resolved (set by @damiendoligez on 2017-03-15T10:20:51Z)
Resolution: won't fix
Priority: normal
Severity: minor
Platform: PC
OS: Windows
OS Version: XP SP3 32 bits
Version: 3.12.1
Target version: undecided
Category: otherlibs
Has duplicate: #4159
Related to: #4549
Monitored by: meyer @protz @xclerc
Bug description
The following snippet will fail with ENOENT on win32/msvc but succeed on linux.
let () =
Unix.mkdir "somedir" 0o755;
ignore (Unix.stat "somedir");
;;
File attachments
The text was updated successfully, but these errors were encountered: