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

Function ddio_GetFileSysRoots

ddio/winfile.cpp:341–377  ·  view source on GitHub ↗

retrieve root names, free up roots array (allocated with malloc) after use

Source from the content-addressed store, hash-verified

339
340// retrieve root names, free up roots array (allocated with malloc) after use
341int ddio_GetFileSysRoots(char **roots, int max_roots) {
342 char buffer[100];
343
344 int ret = GetLogicalDriveStrings(100, buffer);
345 if (ret == 0) {
346 // there was an error
347 return 0;
348 }
349
350 if (ret > 100) {
351 // we didn't have enough space
352 return 0;
353 }
354
355 int count = 0;
356 bool done = false;
357 char *strptr = buffer;
358 char *string;
359 int strsize;
360 while ((count < max_roots) && (!done)) {
361 if (*strptr != 0) {
362 strsize = strlen(strptr);
363 string = roots[count] = (char *)mem_malloc(strsize);
364 if (!string)
365 break;
366 // remove the trailing \ from windows
367 strncpy(string, strptr, strsize - 1);
368 string[strsize - 1] = '\0';
369
370 strptr += (strsize + 1);
371
372 count++;
373 } else
374 done = true;
375 }
376 return count;
377}
378
379// given a path, it cleans it up (if the path is c:\windows\..\dos it would make it c:\dos)
380// srcPath is the original path

Callers 2

OnInitDialogMethod · 0.50
UpdateFileListFunction · 0.50

Calls

no outgoing calls

Tested by

no test coverage detected