Created
March 15, 2015 08:01
-
-
Save unak/ae867785bc32d4d004fe to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#define UNICODE | |
#include <windows.h> | |
#include <stdio.h> | |
int wmain(int argc, WCHAR **argv) | |
{ | |
BY_HANDLE_FILE_INFORMATION info; | |
WIN32_FILE_ATTRIBUTE_DATA attr; | |
int ret = 0; | |
HANDLE h; | |
if (argc != 2) { | |
printf("Usage: stat <path>\n"); | |
return 1; | |
} | |
h = CreateFile(argv[1], 0, 0, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL); | |
if (h == INVALID_HANDLE_VALUE) { | |
printf("error in CreateFile: %d\n", GetLastError()); | |
return 2; | |
} | |
if (GetFileInformationByHandle(h, &info)) { | |
printf("fstat\n"); | |
printf("volume %x\n", info.dwVolumeSerialNumber); | |
printf("size-high %d\n", info.nFileSizeHigh); | |
printf("size-low %d\n", info.nFileSizeLow); | |
printf("links %d\n", info.nNumberOfLinks); | |
printf("idx-high %d\n", info.nFileIndexHigh); | |
printf("idx-low %d\n", info.nFileIndexLow); | |
if (GetFileAttributesEx(argv[1], GetFileExInfoStandard, &attr)) { | |
printf("\nstat\n"); | |
printf("size-high %d\n", attr.nFileSizeHigh); | |
printf("size-low %d\n", attr.nFileSizeLow); | |
} | |
else { | |
printf("error in GetFileAttributesEx: %d\n", GetLastError()); | |
ret = 3; | |
} | |
} | |
else { | |
printf("error in GetFileInformationByHandle: %d\n", GetLastError()); | |
ret = 4; | |
} | |
CloseHandle(h); | |
return ret; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment