Re: File exist
- From: Mr John FO Evans <mijas@xxxxxxxxxxxxxxxxx>
- Date: Tue, 18 Apr 2006 18:12:05 BST
In article <76reh3xu85.ln2@xxxxxxxxxxxxxxxxxxxxxxx>, Flash Gordon
<spam@xxxxxxxxxxxxxxxxxx> wrote:
Claude Yih wrote:
Keith Thompson wrote:
ed <ed@xxxxxxxxxxx> writes:
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.
Try using stat(5).There is no stat() function in standard C. Using it will limit the
portability of your code. See comp.unix.programmer.
I learnt from others that there is a function named access can be used
to detect if a dedicated file exists. The function is as follows:
int access (char* filename, int mode)
For instance, if I wanted to know whether /opt/test.log exists, I would
call this function as
int flag = access("/opt/test.log", 0);
However, this function is included in <io.h>, perhaps it's not a
standard function either.
It is not part of standard C. As I'm sure others have said in this
thread standard C does not provide any portable method to see if a file
exists. So you can be sure that any method you find goes beyond what
standard C provides.
What is wrong with attempting to open the file and if there is no error
closing it again? Surely this is standard 'C'?
John
--
_ _________________________________________
/ \._._ |_ _ _ /' Orpheus Internet Services
\_/| |_)| |(/_|_|_> / 'Internet for Everyone'
_______ | ___________./ http://www.orpheusinternet.co.uk
.
- Follow-Ups:
- Re: File exist
- From: Keith Thompson
- Re: File exist
- From: Flash Gordon
- Re: File exist
- From: Kenneth Brody
- Re: File exist
- References:
- File exist
- From: paytam
- Re: File exist
- From: ed
- Re: File exist
- From: Keith Thompson
- Re: File exist
- From: Claude Yih
- Re: File exist
- From: Flash Gordon
- File exist
- Prev by Date: Re: Different code behaviour in Unix & Windows
- Next by Date: Re: Old question?
- Previous by thread: Re: File exist
- Next by thread: Re: File exist
- Index(es):
Relevant Pages
|