Redundant question since search is down.

Started by
3 comments, last by daerid 21 years, 6 months ago
I need to know the best way to go about finding whether or not a given directory exists programatically (Win32).
daerid@gmail.com
Advertisement
Look at the _stat family of functions:
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);}  
E8 17 00 42 CE DC D2 DC E4 EA C4 40 CA DA C2 D8 CC 40 CA D0 E8 40E0 CA CA 96 5B B0 16 50 D7 D4 02 B2 02 86 E2 CD 21 58 48 79 F2 C3
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.
daerid@gmail.com
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