From: "Ara.T.Howard" Date: 2005-06-13T03:40:30+09:00 Subject: Re: File.link() error message On Sun, 12 Jun 2005, a slow loris wrote: > Why does File.link() report that the source file exists? It really > ought to only report that the destination file exists. It isn't an > error for the source to exist. If it didn't, we'd get ENOENT, not > EEXIST. ENOENT is returned only if harp:~ > man 2 link ... ... SYNOPSIS #include int link(const char *oldpath, const char *newpath); ... ... ENOENT A directory component in oldpath or newpath does not exist or is a dangling symbolic link. otherwise ENOEXIST is returned as this shows harp:~ > cat a.c #include #include #include #include #include main (int argc, char **argv) { char command[256]; link (argv[1], argv[2]); sprintf (command, "ruby -e'p(SystemCallError::new(%d))'", errno); system(command); } harp:~ > gcc a.c harp:~ > ls foo ls: foo: No such file or directory harp:~ > ls bar ls: bar: No such file or directory harp:~ > a.out foo bar # ENOENT is returned if we are dealing with bad directories only harp:~ > a.out /no/such/path/foo bar # harp:~ > a.out foo /no/such/path/bar # but two good dirs always result in ENOEXIST harp:~ > a.out /usr/foo /usr/bar # and a subsequent stat to determine which pathname did not exist would be a race condition so i think you are stuck with this. cheers. -a -- =============================================================================== | email :: ara [dot] t [dot] howard [at] noaa [dot] gov | phone :: 303.497.6469 | My religion is very simple. My religion is kindness. | --Tenzin Gyatso ===============================================================================