fix child dir problem

This commit is contained in:
Kyle Isom 2025-05-01 17:12:28 -07:00
parent b334cf60ad
commit 59dddd91da
2 changed files with 6 additions and 6 deletions

View File

@ -149,20 +149,20 @@ _rmdirs(const char *path)
DIR *dirp;
int fail = EXIT_SUCCESS;
printf("_rmdirs(%s)\n", path);
if (NULL == (dirp = opendir(path))) {
return EXIT_FAILURE;
}
while (NULL != (dp = readdir(dirp))) {
if (0 == strncmp("..", dp->d_name, 3)) {
continue;
}
if (0 == strncmp(".", dp->d_name, 2)) {
continue;
}
snprintf(child, FILENAME_MAX, "%s/%s", path, dp->d_name);
if (DT_DIR == dp->d_type) {
fail = _rmdirs(child);
if (EXIT_FAILURE == fail) {

View File

@ -45,7 +45,7 @@ test_exists(void)
char testfil[] = "testdata/testfile";
char testnot[] = "testdata/nosuchfile";
EXISTS_STATUS ftype;
ftype = path_exists(testdir);
CU_ASSERT(EXISTS_DIR == ftype);
@ -89,7 +89,7 @@ test_empty_rmdirs(void)
printf("\n");
warn("rmdirs");
system("rm -fr testdata/foo/");
}
}
CU_ASSERT(EXIT_SUCCESS == rv);
CU_ASSERT(EXISTS_NOENT == path_exists(testpath));
/*
@ -119,7 +119,7 @@ test_rmdirs_simple(void)
* we can't guarantee rmdirs yet; this ensures a clean slate.
*/
system("rm -r testdata/foo/ 2>/dev/null");
}
}
CU_ASSERT(EXIT_SUCCESS == rv);
CU_ASSERT(EXISTS_NOENT == path_exists(testpath));
}