User Tools

Site Tools


check_directory_existence

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

check_directory_existence [2008/06/10 23:04] (current)
Line 1: Line 1:
 +====== Check directory existence ======
  
 +The following code checks for the existence of a directory on the filesystem.
 +
 +
 +<code c>#​define WIN32_LEAN_AND_MEAN
 +#include <​windows.h>​
 +
 +#ifndef INVALID_FILE_ATTRIBUTES
 +#define INVALID_FILE_ATTRIBUTES ((DWORD)-1)
 +#endif
 +
 +/*
 +    Returns TRUE if filename parameter is a directory
 +    or FALSE if filename is either NULL or a file
 +*/
 +
 +BOOL IsDir(const char *filename)
 +{
 + DWORD dwAttrs; ​
 + 
 + dwAttrs = GetFileAttributes(filename);​
 + if (dwAttrs == INVALID_FILE_ATTRIBUTES)
 + return FALSE;
 +
 + return (BOOL) (dwAttrs & FILE_ATTRIBUTE_DIRECTORY);​
 +}</​code>​
check_directory_existence.txt ยท Last modified: 2008/06/10 23:04 by crl