Date: Sun, 26 Jul 1998 13:23:07 +0300 (IDT) From: Eli Zaretskii To: Bill Currie cc: djgpp-workers AT delorie DOT com Subject: Re: A Quiz In-Reply-To: <35B43F34.8060D2DA@taniwha.tssc.co.nz> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Precedence: bulk > 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.