Redundant question since search is down.
I need to know the best way to go about finding whether or not a given directory exists programatically (Win32).
Look at the _stat family of functions:
Hope this helps;
Cheers, dorix
struct stat myStat;int ret = _stat("C:\\Windows", &myStat);if (ret != 0) { // Some error occured, path probably doesn''t exist. // Check the errno global variable for more info.} else { if (myStat.st_mode & _S_IFDIR) { // Yes, it exists and it is a directory. } else { // Exists, but it''s not a directory. }}
Hope this helps;
Cheers, dorix
int dir_exists(char* filename){ DWORD fa = GetFileAttributes(filename); return (fa != -1 && fa & FILE_ATTRIBUTE_DIRECTORY);}
quote:Original post by Jan Wassenberg
int dir_exists(char* filename){ DWORD fa = GetFileAttributes(filename); return (fa != -1 && fa & FILE_ATTRIBUTE_DIRECTORY);}
I''m gonna mail you a chocolate chip cookie.
You rock! thanks.
quote:Original post by Jan Wassenberg
int dir_exists(char* filename){ DWORD fa = GetFileAttributes(filename); return (fa != -1 && fa & FILE_ATTRIBUTE_DIRECTORY);}
That''s way better than mine. That''s what I get for thinking Unix before Win32.
Cheers, dorix
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement