I am trying to use access()
to see if a file exists; however, it is not working as expected. The current implementation is like so:
void checkFile(char * file)
{
if (access(file, F_OK) != -1){
//Do things
}else{
//Return an Error
}
}
This is just an extract of how I am using it. However, it always hits the else
statement and returns an error for a file that exists. I have used absolute paths, relative paths and it is still not working.
Can you see what is going wrong?