Batch #12295 by cremane: 0 byte-identical, 2 confirmed by peer review. - fn_18246 EnumerateFileNames: logic confirmed by peer review - fn_18247 EnumerateFileNames: logic confirmed by peer review Peer-reviewed-by: Yommy, gordaoprogramas, dori Accepted without human review: peers confirmed the logic ("same" ahead by at least 3, with 70% of the votes).
47 lines
1.3 KiB
C++
47 lines
1.3 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("..");
|
|
do {
|
|
if (current != found.cFileName && parent != found.cFileName) {
|
|
names.push_back(std::string(found.cFileName));
|
|
}
|
|
} while (FindNextFileA(handle, &found));
|
|
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("..");
|
|
do {
|
|
if (current != found.cFileName && parent != found.cFileName) {
|
|
names.push_back(std::string(found.cFileName));
|
|
}
|
|
} while (FindNextFileA(handle, &found));
|
|
FindClose(handle);
|
|
}
|