#include "PlatAPI.h" #include #include using namespace std; vector ListDir(const std::string& dirName) { vector vec; WIN32_FIND_DATAA findData; LARGE_INTEGER filesize; string patternName = dirName + "\\*"; HANDLE hand = FindFirstFileA(patternName.c_str(), &findData); if (hand == INVALID_HANDLE_VALUE) { cout << "Failed to ListDir: " << GetLastError() << endl; return vec; } do { FileInfo f; f.name = std::string(findData.cFileName); if (f.name == "." || f.name == "..") continue; if (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { f.type = 1; f.size = 0; } else { f.type = 0; filesize.LowPart = findData.nFileSizeLow; filesize.HighPart = findData.nFileSizeHigh; f.size = filesize.QuadPart; } vec.push_back(f); } while (FindNextFileA(hand, &findData)); FindClose(hand); return vec; }