fix child dir problem
This commit is contained in:
parent
b334cf60ad
commit
59dddd91da
|
@ -149,20 +149,20 @@ _rmdirs(const char *path)
|
||||||
DIR *dirp;
|
DIR *dirp;
|
||||||
int fail = EXIT_SUCCESS;
|
int fail = EXIT_SUCCESS;
|
||||||
|
|
||||||
printf("_rmdirs(%s)\n", path);
|
|
||||||
if (NULL == (dirp = opendir(path))) {
|
if (NULL == (dirp = opendir(path))) {
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (NULL != (dp = readdir(dirp))) {
|
while (NULL != (dp = readdir(dirp))) {
|
||||||
if (0 == strncmp("..", dp->d_name, 3)) {
|
if (0 == strncmp("..", dp->d_name, 3)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 == strncmp(".", dp->d_name, 2)) {
|
if (0 == strncmp(".", dp->d_name, 2)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
snprintf(child, FILENAME_MAX, "%s/%s", path, dp->d_name);
|
||||||
if (DT_DIR == dp->d_type) {
|
if (DT_DIR == dp->d_type) {
|
||||||
fail = _rmdirs(child);
|
fail = _rmdirs(child);
|
||||||
if (EXIT_FAILURE == fail) {
|
if (EXIT_FAILURE == fail) {
|
||||||
|
|
|
@ -45,7 +45,7 @@ test_exists(void)
|
||||||
char testfil[] = "testdata/testfile";
|
char testfil[] = "testdata/testfile";
|
||||||
char testnot[] = "testdata/nosuchfile";
|
char testnot[] = "testdata/nosuchfile";
|
||||||
EXISTS_STATUS ftype;
|
EXISTS_STATUS ftype;
|
||||||
|
|
||||||
ftype = path_exists(testdir);
|
ftype = path_exists(testdir);
|
||||||
CU_ASSERT(EXISTS_DIR == ftype);
|
CU_ASSERT(EXISTS_DIR == ftype);
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ test_empty_rmdirs(void)
|
||||||
printf("\n");
|
printf("\n");
|
||||||
warn("rmdirs");
|
warn("rmdirs");
|
||||||
system("rm -fr testdata/foo/");
|
system("rm -fr testdata/foo/");
|
||||||
}
|
}
|
||||||
CU_ASSERT(EXIT_SUCCESS == rv);
|
CU_ASSERT(EXIT_SUCCESS == rv);
|
||||||
CU_ASSERT(EXISTS_NOENT == path_exists(testpath));
|
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.
|
* we can't guarantee rmdirs yet; this ensures a clean slate.
|
||||||
*/
|
*/
|
||||||
system("rm -r testdata/foo/ 2>/dev/null");
|
system("rm -r testdata/foo/ 2>/dev/null");
|
||||||
}
|
}
|
||||||
CU_ASSERT(EXIT_SUCCESS == rv);
|
CU_ASSERT(EXIT_SUCCESS == rv);
|
||||||
CU_ASSERT(EXISTS_NOENT == path_exists(testpath));
|
CU_ASSERT(EXISTS_NOENT == path_exists(testpath));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue