Jump to content

[Tutorial] Functie customizata: file_exists


Recommended Posts

Guest claudiuhks
Posted

file_exists intoarce true daca fisierul exista indiferent ca este fisier sau director!


bool file_exists( char *cFile )
{
#if defined __linux__
struct stat s;

if( stat( cFile, &s ) != 0 )
return false;

return true;
#else
if( GetFileAttributes( cFile ) == INVALID_FILE_ATTRIBUTES )
return false;

return true;
#endif
}

Guest claudiuhks
Posted

Un exemplu util:


int main( )
{
if( file_exists( "myfile.txt" ) )
{
FILE *fFile = fopen( "myfile.txt", "r" );
fclose( fFile );
}

return 1;
}

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.