Mail Archives: djgpp-workers/1998/07/26/06:23:11
> Assuming that foo.c exists and is a file (not a directory), what will
> be the value of `i' after this line executes on DOS/Windows:
>
> int i = access ("foo.c/.", F_OK);
I didn't get too many replies (guess you didn't find it amusing enough
after all ;-), but here's the solution anyway:
This yields zero, i.e. success. The reason is that DOS/Windows
canonicalizes the file name (by an equivalent of `_truename') *before*
it even looks at it, and the canonicalization blindly strips off any
"/." components, without checking whether the previous component is a
directory.
Bill Currie gets the first prize, for explaining exactly that.
This problem got me puzzled for a few minutes when I compiled the
latest timezone-related code (to be included in v2.02). It would
complain about being unable to remove a previous version of a file
before creating a new one, because the code wanted to be extra-careful
(on Unix) to not remove a directory instead of a file.
- Raw text -