MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / FindAllFiles

Function FindAllFiles

Descent3/pilot.cpp:2256–2282  ·  view source on GitHub ↗

FindAllFiles Retrieves the files in the current directory that match the pattern given. Call FindAllFilesSize() to determine how much memory will be needed for the buffer. pattern = wildcard pattern to use to match list = buffer of memory that will be filled in with the filenames (each seperated by a \0) size = size of memory allocated for list parm filecount = filled in with the number of file

Source from the content-addressed store, hash-verified

2254// size = size of memory allocated for list parm
2255// filecount = filled in with the number of files it found
2256int FindAllFiles(const char *pattern, char *list, int size, int *filecount) {
2257 int count = 0;
2258 char filename[_MAX_PATH];
2259 *filecount = 0;
2260 int memory = 0;
2261
2262 if (size <= 0)
2263 return 0;
2264 if (!list)
2265 return 0;
2266 if (!pattern)
2267 return 0;
2268
2269 if (ddio_FindFileStart(pattern, filename)) {
2270 count++;
2271 strcpy(&list[memory], filename);
2272 memory += strlen(&list[memory]) + 1;
2273 while ((count < size) && (ddio_FindNextFile(filename))) {
2274 strcpy(&list[memory], filename);
2275 memory += strlen(&list[memory]) + 1;
2276 count++;
2277 }
2278 }
2279 ddio_FindFileClose();
2280 *filecount = count;
2281 return memory;
2282}
2283
2284// FindAllFilesSize
2285//

Callers 1

UpdateGraphicsListboxFunction · 0.85

Calls 3

ddio_FindFileStartFunction · 0.50
ddio_FindNextFileFunction · 0.50
ddio_FindFileCloseFunction · 0.50

Tested by

no test coverage detected