Possible Duplicate:
C check if file exists
I was just wondering if someone could point me in the right direction regarding to how I should go about checking if a file exists? At this point in time I plan on going with something along the lines of the following;
if(NULL==(fp=fopen(filepath, "r"))){
my ultimate goal would be to find a solution to replace this in bash (just the file finding part)
if ! (find /dev/shm/request-summon-*-$MCEXEC_PLAYERNAME.txt > /dev/null 2>&1); then
any help is really appreciated, thanks!
Look at the manual page for
stat()also coveringlstat()andfstat(). If you get -1 as the return value, the file you tried to get summary information on does not exist, or may not have rights to read it (see last example below which shows the difference from yourfopen()test as a file may exist but not let you open it).