c Sprawdź, czy plik istnieje
if( access( fname, F_OK ) == 0 ) {
// file exists
} else {
// file doesn't exist
}
chfle
if( access( fname, F_OK ) == 0 ) {
// file exists
} else {
// file doesn't exist
}
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
int is_regular_file(const char *path)
{
struct stat path_stat;
stat(path, &path_stat);
return S_ISREG(path_stat.st_mode);
}
int canCreateFile(char* path)
{
FILE* file = fopen(path, "w");
if(file)
{
fclose(file);
return 1;
}
return 0;
}