cvs.gedasymbols.org/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1998/07/26/06:23:11

Date: Sun, 26 Jul 1998 13:23:07 +0300 (IDT)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: Bill Currie <bill AT taniwha DOT tssc DOT co DOT nz>
cc: djgpp-workers AT delorie DOT com
Subject: Re: A Quiz
In-Reply-To: <35B43F34.8060D2DA@taniwha.tssc.co.nz>
Message-ID: <Pine.SUN.3.91.980726132141.26805B-100000@is>
MIME-Version: 1.0

>   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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019