Created
January 30, 2011 22:11
-
-
Save luislavena/803316 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <windows.h> | |
#include <stdio.h> | |
int run(CHAR *path) | |
{ | |
WIN32_FILE_ATTRIBUTE_DATA wfad; | |
int a, e; | |
printf("Checking '%s'\n", path); | |
a = GetFileAttributesEx(path, GetFileExInfoStandard, &wfad); | |
printf("Result: %d\n", a); | |
if (a) { | |
printf("wfad.dwFileAttributes: %d\n", wfad.dwFileAttributes); | |
if (wfad.dwFileAttributes & FILE_ATTRIBUTE_ARCHIVE) printf("FILE_ATTRIBUTE_ARCHIVE\n"); | |
if (wfad.dwFileAttributes & FILE_ATTRIBUTE_COMPRESSED) printf("FILE_ATTRIBUTE_COMPRESSED\n"); | |
if (wfad.dwFileAttributes & FILE_ATTRIBUTE_DEVICE) printf("FILE_ATTRIBUTE_DEVICE\n"); | |
if (wfad.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) printf("FILE_ATTRIBUTE_DIRECTORY\n"); | |
if (wfad.dwFileAttributes & FILE_ATTRIBUTE_ENCRYPTED) printf("FILE_ATTRIBUTE_ENCRYPTED\n"); | |
if (wfad.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) printf("FILE_ATTRIBUTE_HIDDEN\n"); | |
if (wfad.dwFileAttributes & FILE_ATTRIBUTE_NORMAL) printf("FILE_ATTRIBUTE_NORMAL\n"); | |
if (wfad.dwFileAttributes & FILE_ATTRIBUTE_NOT_CONTENT_INDEXED) printf("FILE_ATTRIBUTE_NOT_CONTENT_INDEXED\n"); | |
if (wfad.dwFileAttributes & FILE_ATTRIBUTE_OFFLINE) printf("FILE_ATTRIBUTE_OFFLINE\n"); | |
if (wfad.dwFileAttributes & FILE_ATTRIBUTE_READONLY) printf("FILE_ATTRIBUTE_READONLY\n"); | |
if (wfad.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) printf("FILE_ATTRIBUTE_REPARSE_POINT\n"); | |
if (wfad.dwFileAttributes & FILE_ATTRIBUTE_SPARSE_FILE) printf("FILE_ATTRIBUTE_SPARSE_FILE\n"); | |
if (wfad.dwFileAttributes & FILE_ATTRIBUTE_SYSTEM) printf("FILE_ATTRIBUTE_SYSTEM\n"); | |
if (wfad.dwFileAttributes & FILE_ATTRIBUTE_TEMPORARY) printf("FILE_ATTRIBUTE_TEMPORARY\n"); | |
if (wfad.dwFileAttributes & FILE_ATTRIBUTE_VIRTUAL) printf("FILE_ATTRIBUTE_VIRTUAL\n"); | |
return -1; | |
} else { | |
e = GetLastError(); | |
if ((e == ERROR_FILE_NOT_FOUND) || (e == ERROR_INVALID_NAME) || | |
(e == ERROR_PATH_NOT_FOUND)) { | |
printf("GetLastError: %d", e); | |
} | |
return 0; | |
} | |
} | |
void find(CHAR *path) | |
{ | |
HANDLE h; | |
WIN32_FIND_DATA fd; | |
int e; | |
printf("FindFirstFile '%s'\n", path); | |
h = FindFirstFile(path, &fd); | |
if (h != INVALID_HANDLE_VALUE) { | |
FindClose(h); | |
printf("fd.cFileName: '%s'", fd.cFileName); | |
} else { | |
e = GetLastError(); | |
printf("GetLastError: %d", e); | |
} | |
} | |
void main() | |
{ | |
CHAR *path; | |
path = "C:/Users/Luis/Projects/oss/oci/rubyinstaller/sandbox"; | |
if (!(run(path))) { | |
find(path); | |
} | |
path = "C:/Users/Luis/Projects/oss/oci/rubyinstaller/sandbox/..."; | |
run(path); | |
find(path); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment