diff --git a/libdirutils/dirutils.c b/libdirutils/dirutils.c index a7666a3..a8ecd24 100644 --- a/libdirutils/dirutils.c +++ b/libdirutils/dirutils.c @@ -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) { diff --git a/libdirutils/dirutils_test.c b/libdirutils/dirutils_test.c index caea49f..13eb48c 100644 --- a/libdirutils/dirutils_test.c +++ b/libdirutils/dirutils_test.c @@ -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)); }