Re: File exist



Mr John FO Evans wrote:
[...]
On 16 Apr 2006 01:53:03 -0700
paytam@xxxxxxxxx wrote:
Can anyone tell me how can I check that a file exist or no.
[...]
What is wrong with attempting to open the file and if there is no error
closing it again? Surely this is standard 'C'?

Because if it fails, it won't (necessarily) tell you why. As has been
pointed out elsethread, insufficient access privileges will fail the
same way as a non-existent file. While many implementations will set
errno to the reason for the failure, such behavior is not guaranteed by
the Standard.

--
+-------------------------+--------------------+-----------------------------+
| Kenneth J. Brody | www.hvcomputer.com | |
| kenbrody/at\spamcop.net | www.fptech.com | #include <std_disclaimer.h> |
+-------------------------+--------------------+-----------------------------+
Don't e-mail me at: <mailto:ThisIsASpamTrap@xxxxxxxxx>

.



Relevant Pages

  • build world build kernel correct order?
    ... i've been having nightmares building my kernel and world on a clean system: ... P4 celeron 128M freebsd5.1 standard no fluff integrated motherboard. ... buildkernel fails in either mode at the same point in the build. ... rerunning cvsup changes the spot that the build fails in. ...
    (freebsd-current)
  • Re: Malloc
    ... standard *could* have provided a method for getting a list of files ... is specific to Unix even though they are provided with Unix type ... I know of systems where opening a binary file in text mode fails. ...
    (comp.lang.c)
  • Re: Malloc
    ... The> standard *could* have provided a method for getting a list of files> where the "file list open" function took a name that the implementation> treated as it wished with no guarantee that the "file list open"> function would succeed and no guarantee that> you can open the files that are listed. ... > There are a number of "unix utilities" that do not rely on anything that> is specific to Unix even though they are provided with Unix type ... I know of systems where opening a binary file in text mode fails. ... So unless you are saying you cannot open *any* file without using some non-standard method to specify which fork the program would still work, ...
    (comp.lang.c)
  • Re: free() unreliable?
    ... In comp.lang.c, nembo kid wrote: ... As far as the C standard goes, freewill free the pointed-to memory space, ... even standard libraries have flaws. ... So, yes, freesometimes fails. ...
    (comp.lang.c)
  • Re: malloc behavior on failure
    ... I know there are a couple of non standard c includes here and the POSIX ... //set subsequent timer intervals ... When the malloc fails the timer stops ... After some research it appears that when malloc ...
    (comp.lang.c)