mirror of https://github.com/decompals/wibo.git
Handle special handle value from FindFirstFileA in FindNextFileA (#52)
This commit is contained in:
parent
97a5af2055
commit
c9d634876d
1
common.h
1
common.h
|
@ -50,6 +50,7 @@ typedef unsigned char BYTE;
|
||||||
#define ERROR_PATH_NOT_FOUND 3
|
#define ERROR_PATH_NOT_FOUND 3
|
||||||
#define ERROR_ACCESS_DENIED 5
|
#define ERROR_ACCESS_DENIED 5
|
||||||
#define ERROR_INVALID_HANDLE 6
|
#define ERROR_INVALID_HANDLE 6
|
||||||
|
#define ERROR_NO_MORE_FILES 18
|
||||||
#define ERROR_READ_FAULT 30
|
#define ERROR_READ_FAULT 30
|
||||||
#define ERROR_HANDLE_EOF 38
|
#define ERROR_HANDLE_EOF 38
|
||||||
#define ERROR_NOT_SUPPORTED 50
|
#define ERROR_NOT_SUPPORTED 50
|
||||||
|
|
|
@ -707,12 +707,12 @@ namespace kernel32 {
|
||||||
return (void *) 1;
|
return (void *) 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
FindFirstFileHandle *handle = new FindFirstFileHandle();
|
auto *handle = new FindFirstFileHandle();
|
||||||
|
|
||||||
if (!std::filesystem::exists(path.parent_path())) {
|
if (!std::filesystem::exists(path.parent_path())) {
|
||||||
wibo::lastError = 3; // ERROR_PATH_NOT_FOUND
|
wibo::lastError = ERROR_PATH_NOT_FOUND;
|
||||||
delete handle;
|
delete handle;
|
||||||
return (void *) 0xFFFFFFFF;
|
return INVALID_HANDLE_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::filesystem::directory_iterator it(path.parent_path());
|
std::filesystem::directory_iterator it(path.parent_path());
|
||||||
|
@ -720,9 +720,9 @@ namespace kernel32 {
|
||||||
handle->pattern = path.filename().string();
|
handle->pattern = path.filename().string();
|
||||||
|
|
||||||
if (!findNextFile(handle)) {
|
if (!findNextFile(handle)) {
|
||||||
wibo::lastError = 2; // ERROR_FILE_NOT_FOUND
|
wibo::lastError = ERROR_FILE_NOT_FOUND;
|
||||||
delete handle;
|
delete handle;
|
||||||
return (void *) 0xFFFFFFFF;
|
return INVALID_HANDLE_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
setFindFileDataFromPath(lpFindFileData, *handle->it++);
|
setFindFileDataFromPath(lpFindFileData, *handle->it++);
|
||||||
|
@ -752,8 +752,15 @@ namespace kernel32 {
|
||||||
}
|
}
|
||||||
|
|
||||||
int WIN_FUNC FindNextFileA(void *hFindFile, WIN32_FIND_DATA<char> *lpFindFileData) {
|
int WIN_FUNC FindNextFileA(void *hFindFile, WIN32_FIND_DATA<char> *lpFindFileData) {
|
||||||
FindFirstFileHandle *handle = (FindFirstFileHandle *) hFindFile;
|
// Special value from FindFirstFileA
|
||||||
|
if (hFindFile == (void *) 1) {
|
||||||
|
wibo::lastError = ERROR_NO_MORE_FILES;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto *handle = (FindFirstFileHandle *) hFindFile;
|
||||||
if (!findNextFile(handle)) {
|
if (!findNextFile(handle)) {
|
||||||
|
wibo::lastError = ERROR_NO_MORE_FILES;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue