rodecomp/Source/File/FileEnumeration.cpp
ragnarok-clanker 4e2f4c03ec Decompile 2 functions in Source/File/FileEnumeration.cpp
Batch #17593 by eAthena: 2 byte-identical, 0 confirmed by peer review.

- fn_18246 EnumerateFileNames: byte-identical
- fn_18247 EnumerateFileNames: byte-identical

Merged automatically: every function is byte-identical to the original.
2026-11-12 01:05:47 +00:00

55 lines
1.5 KiB
C++

#include "File/FileEnumeration.h"
#include <windows.h>
// OFFSET: 0x00AF5080
// FUNCTION: fn_18246
void EnumerateFileNames(std::list<std::string>& names, const char* directory, const char* pattern) {
std::string search(directory);
search.append(pattern);
WIN32_FIND_DATAA found{};
HANDLE handle = FindFirstFileA(search.c_str(), &found);
if (handle == INVALID_HANDLE_VALUE) {
FindClose(handle);
return;
}
const std::string current(".");
const std::string parent("..");
if (current != found.cFileName && parent != found.cFileName) {
names.push_back(std::string(found.cFileName));
}
while (FindNextFileA(handle, &found)) {
if (current != found.cFileName && parent != found.cFileName) {
names.push_back(std::string(found.cFileName));
}
}
FindClose(handle);
}
// OFFSET: 0x00AF5510
// FUNCTION: fn_18247
void EnumerateFileNames(std::vector<std::string>& names, const char* directory, const char* pattern) {
std::string search(directory);
search.append(pattern);
WIN32_FIND_DATAA found{};
HANDLE handle = FindFirstFileA(search.c_str(), &found);
if (handle == INVALID_HANDLE_VALUE) {
FindClose(handle);
return;
}
const std::string current(".");
const std::string parent("..");
if (current != found.cFileName && parent != found.cFileName) {
names.push_back(std::string(found.cFileName));
}
while (FindNextFileA(handle, &found)) {
if (current != found.cFileName && parent != found.cFileName) {
names.push_back(std::string(found.cFileName));
}
}
FindClose(handle);
}