Created
May 21, 2019 10:03
-
-
Save thrimbor/34f1914f9c62f5b584bc382605d854a6 to your computer and use it in GitHub Desktop.
WinAPI file finding test code
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 <stdio.h> | |
#include <fileapi.h> | |
#include <hal/winerror.h> | |
#include <xboxrt/debug.h> | |
#include <pbkit/pbkit.h> | |
#include <hal/xbox.h> | |
void listAll(const char * path) | |
{ | |
WIN32_FIND_DATA findFileData; | |
HANDLE hFind; | |
debugPrint("%s\n", path); | |
// Like on Windows, "*.*" and "*" will both list all files, | |
// no matter whether they contain a dot or not | |
hFind = FindFirstFile(path, &findFileData); | |
if (hFind == INVALID_HANDLE_VALUE) { | |
debugPrint("FindFirstHandle() failed!\n"); | |
return; | |
} | |
do { | |
if (findFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { | |
debugPrint("Directory: "); | |
} else { | |
debugPrint("File : "); | |
} | |
debugPrint("%s\n", findFileData.cFileName); | |
} while (FindNextFile(hFind, &findFileData) != 0); | |
debugPrint("\n"); | |
DWORD error = GetLastError(); | |
if (error != ERROR_NO_MORE_FILES) { | |
debugPrint("error: %x\n", error); | |
} | |
FindClose(hFind); | |
} | |
int main() | |
{ | |
int ret = pb_init(); | |
if (ret != 0) { | |
XSleep(2000); | |
return -1; | |
} | |
pb_show_debug_screen(); | |
listAll("C:\\*"); | |
listAll("C:\\x*"); | |
listAll("C:\\x??x*"); | |
while (1) { | |
XSleep(2000); | |
} | |
pb_kill(); | |
XReboot(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment