Mail Archives: cygwin/2005/07/09/12:32:51
On Sat, Jul 09, 2005 at 06:08:08AM -0600, Eric Blake wrote:
>-----BEGIN PGP SIGNED MESSAGE-----
>Hash: SHA1
>
>According to Christopher Faylor on 7/8/2005 11:02 PM:
>> I don't get it. Certainly /cygdrive/c.exe doesn't exist so why would you
>> try to link to it?
>
>The algorithm I used was this:
>
>1 - If source exists [determined by the return value of readlink
>("source"), although just now I realized that for symbolic links, it
>should really be the return value of readlink (concat (dirname ("dest"),
>"source")) since symbolic links are relative to the destination, not the pwd]
> 2a - if source is non-symlink and exists with a trailing . [determined by
>access ("source.")] use "source", else use "source.exe", because one of
>those two spellings must have made test 1 succeed
> 2b - if source is symlink and exists with a trailing .lnk [determined by
>readlink ("source.lnk")] use "source", else use "source.exe", because one
>of those two spellings must have made test 1 succeed
>
>I think the cleanup needs to be along these lines - in steps 2a and 2b, do
>a sanity check of also checking whether "source.exe" exists.
I don't know why you'd ever just assume that .exe exists.
Wouldn't it be safer to just do:
struct stat st1, st2;
stat ("foo", &st1);
if (stat ("foo.exe", &st2) == 0 && st2.st_ino == st1.st_ino)
return "foo.exe";
else
return "foo";
You could add st_dev checking, too, if you were really paranoid.
cgf
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
- Raw text -