vendredi 8 mai 2015

How can I use access method for file extension?

I use access in order to understand file is exist or not.

char file[100];
strcpy(file, "/home/asd/test.txt");
if(access(file, F_OK) >= 0)
{
    printf("file is exist \n");
}
else
{
    printf("file is not exist \n");
}

I try to understand is there any file with txt extension or not so I want to use this code for file extension not file name. How can I do that?

Aucun commentaire:

Enregistrer un commentaire