MCPcopy Create free account
hub / github.com/Singular/Singular / ListFileTree

Function ListFileTree

ppcc/adlib/os.cc:308–330  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

306}
307
308StrArr *ListFileTree(const char *path, int mode) {
309 StrArr *result = new StrArr();
310 FileInfo info;
311 if (FileStat(info, path, true)) {
312 if (info.is_dir) {
313 Str *dir = new Str(path);
314 if (!dir->ends_with(PathSeparator))
315 dir->add(PathSeparator);
316 Int prefixlen = dir->len();
317 result->add(dir);
318 WalkDir(result, dir->c_str(), mode);
319 if (mode & ListFilesRelative) {
320 for (Int i = 0; i < result->len(); i++) {
321 result->at(i)->remove(0, prefixlen);
322 }
323 }
324 } else {
325 if ((mode & ListFilesRelative) == 0)
326 result->add(S(path));
327 }
328 }
329 return result;
330}
331
332StrArr *ListFileTree(Str *path, int mode) {
333 return ListFileTree(path->c_str(), mode);

Callers 1

MainFunction · 0.85

Calls 9

FileStatFunction · 0.85
WalkDirFunction · 0.85
ends_withMethod · 0.80
c_strMethod · 0.80
SFunction · 0.70
addMethod · 0.45
lenMethod · 0.45
removeMethod · 0.45
atMethod · 0.45

Tested by 1

MainFunction · 0.68