mirror of
https://gitlab.com/fbb-git/cppannotations
synced 2024-09-28 03:20:44 +02:00
37 lines
761 B
Text
37 lines
761 B
Text
void removeDir(string dir)
|
|
{
|
|
list parts;
|
|
int idx;
|
|
int dirIdx;
|
|
list entries;
|
|
int warn = 1;
|
|
|
|
if (!exists(dir)) // directory was already removed
|
|
return;
|
|
|
|
parts = findAll("d", dir, ""); // if there are still subdirs
|
|
if (listlen(parts) != 0) // then remove at some later stage
|
|
return;
|
|
|
|
chdir(dir);
|
|
parts = strtok(dir, "/");
|
|
|
|
for (idx = listlen(parts); idx--; )
|
|
{
|
|
entries = backtick("ls -A");
|
|
|
|
if (listlen(entries) != 0)
|
|
{
|
|
if (warn)
|
|
printf("not removing non-empty dir ", dir, "\n");
|
|
return;
|
|
}
|
|
|
|
warn = 0;
|
|
chdir("..");
|
|
run("rmdir " + parts[idx]);
|
|
}
|
|
}
|
|
|
|
|
|
|