MCPcopy Create free account
hub / github.com/PenguLoader/PenguLoader / read_dir

Method read_dir

core/src/utils/file.cc:99–129  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

97}
98
99std::vector<path> file::read_dir(const path &dir)
100{
101 std::vector<path> files;
102 files.clear();
103
104#if OS_WIN
105 std::wstring target = dir.wstring() + L"\\*";
106 WIN32_FIND_DATAW fd;
107 HANDLE hFind = FindFirstFileW(target.c_str(), &fd);
108
109 if (hFind != INVALID_HANDLE_VALUE) {
110 do {
111 files.push_back(fd.cFileName);
112 } while (FindNextFileW(hFind, &fd));
113 FindClose(hFind);
114 }
115#elif OS_MAC
116 if (DIR *pdir = opendir(dir.string().c_str())) {
117 struct dirent *entry = readdir(pdir);
118 while (entry != NULL) {
119 if (entry->d_type & (DT_REG | DT_DIR)) {
120 files.push_back(entry->d_name);
121 }
122 entry = readdir(pdir);
123 }
124 closedir(pdir);
125 }
126#endif
127
128 return files;
129}

Callers

nothing calls this directly

Calls 1

stringMethod · 0.80

Tested by

no test coverage detected