From: Ethan M. <merritt@u.washington.edu> - 2006-03-03 01:32:44
|
On Thursday 02 March 2006 02:10 pm, Petr Mikulik wrote: > What do you think about adding function > fileexist("a.dat") > that would return 1 or 0 if file exists or does not exist? > > I have already needed that several times ... solution via `test` is > not portable ... Is access() really that much more portable than test? > The code is as easy as > return (access(filename, F_OK) != 0)) > see the attachment. man 2 access [...] RESTRICTIONS access may not work correctly on NFS file systems with UID mapping enabled, because UID mapping is done on the server and hidden from the client, which checks permissions. If your test doesn't work across NFS-mounted volumes, that's not very portable! Can you give an example of why such a thing is needed? -- Ethan A Merritt Biomolecular Structure Center University of Washington, Seattle WA |