Re: File exist
- From: ed <ed@xxxxxxxxxxx>
- Date: Sun, 16 Apr 2006 13:58:37 GMT
On 16 Apr 2006 01:53:03 -0700
paytam@xxxxxxxxx wrote:
Hi all
Can anyone tell me how can I check that a file exist or no.I mean when
you use this commands
FILE *fp;
if(!fp)
//Could not open the file
doen't show why it can not open it,may be the file doesn't exist.Now
tell me what should I do!
Try using stat(5).
NAME
stat, fstat, lstat - get file status
SYNOPSIS
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
int stat(const char *file_name, struct stat *buf);
int fstat(int filedes, struct stat *buf);
int lstat(const char *file_name, struct stat *buf);
DESCRIPTION
These functions return information about the specified file.
You do not need any access rights to the file to get this
information but you need search rights to all directories named
in the path leading to the file.
stat stats the file pointed to by file_name and fills in buf.
See the full man page for further details if you think it might be of
use.
--
Regards, Ed :: http://www.s5h.net
:%s/\t/ /g :: proud unix system person
:%s/Open Source/Free Software/g
.
- Follow-Ups:
- Re: File exist
- From: Keith Thompson
- Re: File exist
- References:
- File exist
- From: paytam
- File exist
- Prev by Date: Re: shift question
- Next by Date: Re: Objects
- Previous by thread: Re: File exist
- Next by thread: Re: File exist
- Index(es):
Relevant Pages
|