How to check if file exists in C++ in a portable way?
Currently I use this code to check if file exists on Windows and
POSIX-compatible OSes:
bool FileExist( const std::string& Name )
{
#ifdef OS_WINDOWS
struct _stat buf;
int Result = _stat( Name.c_str(), &buf );
#else
struct stat buf;
int Result = stat( Name.c_str(), &buf );
No comments:
Post a Comment