MCPcopy Create free account
hub / github.com/crownengine/crown / list_files

Function list_files

src/core/os.cpp:263–308  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

261 }
262
263 void list_files(const char *path, Vector<DynamicString> &files)
264 {
265#if CROWN_PLATFORM_WINDOWS
266 TempAllocator256 ta_path;
267 DynamicString cur_path(ta_path);
268 cur_path += path;
269 cur_path += "\\*";
270
271 WIN32_FIND_DATA ffd;
272 HANDLE file = FindFirstFile(cur_path.c_str(), &ffd);
273 if (file != INVALID_HANDLE_VALUE) {
274 do {
275 const char *dname = ffd.cFileName;
276
277 if (!strcmp(dname, ".") || !strcmp(dname, ".."))
278 continue;
279
280 TempAllocator256 ta;
281 DynamicString fname(ta);
282 fname.set(dname, strlen32(dname));
283 vector::push_back(files, fname);
284 } while (FindNextFile(file, &ffd) != 0);
285
286 FindClose(file);
287 }
288#else
289 struct dirent *entry;
290
291 DIR *dir = opendir(path);
292 if (dir != NULL) {
293 while ((entry = readdir(dir))) {
294 const char *dname = entry->d_name;
295
296 if (!strcmp(dname, ".") || !strcmp(dname, ".."))
297 continue;
298
299 TempAllocator256 ta;
300 DynamicString fname(ta);
301 fname.set(dname, strlen32(dname));
302 vector::push_back(files, fname);
303 }
304
305 closedir(dir);
306 }
307#endif // if CROWN_PLATFORM_WINDOWS
308 }
309
310 ///
311 s32 access(const char *path, u32 flags)

Callers 1

list_filesMethod · 0.85

Calls 7

strcmpFunction · 0.85
FindCloseFunction · 0.85
opendirFunction · 0.50
readdirFunction · 0.50
closedirFunction · 0.50
c_strMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected