diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/kit/file.c | 13 | ||||
-rw-r--r-- | source/tests/file.test.c | 14 |
2 files changed, 8 insertions, 19 deletions
diff --git a/source/kit/file.c b/source/kit/file.c index df94d59..52b27fa 100644 --- a/source/kit/file.c +++ b/source/kit/file.c @@ -301,12 +301,15 @@ kit_status_t kit_file_remove_recursive(kit_str_t path, case KIT_PATH_FOLDER: { kit_path_list_t list = kit_folder_enum(path, alloc); + printf(" >> 1 \n"); fflush(stdout); + assert(list.status == KIT_OK); if (list.status != KIT_OK) { kit_path_list_destroy(list); return list.status; } + printf(" >> 2 \n"); fflush(stdout); for (i = 0; i < list.files.size; i++) { str_builder_t full_path = kit_path_join( path, WRAP_STR(list.files.values[i]), alloc); @@ -316,8 +319,10 @@ kit_status_t kit_file_remove_recursive(kit_str_t path, assert(s == KIT_OK); } + printf(" >> 3 \n"); fflush(stdout); kit_path_list_destroy(list); + printf(" >> 4 \n"); fflush(stdout); kit_status_t s = kit_folder_remove(path); assert(s == KIT_OK); return s; @@ -413,20 +418,15 @@ kit_path_list_t kit_folder_enum(kit_str_t path, return result; } - printf(" >> 1 \n"); fflush(stdout); - buf[path.size + 4] = '\\'; buf[path.size + 5] = '*'; - printf(" >> 1 \n"); fflush(stdout); WIN32_FIND_DATAW data; HANDLE find = FindFirstFileA(buf, &data); - printf(" >> 2 \n"); fflush(stdout); if (find == INVALID_HANDLE_VALUE) return result; - printf(" >> 3 \n"); fflush(stdout); do { i64 n = result.files.size; DA_RESIZE(result.files, n + 1); @@ -435,7 +435,6 @@ kit_path_list_t kit_folder_enum(kit_str_t path, break; } - printf(" >> 4 \n"); fflush(stdout); i64 size = 0; while (size < MAX_PATH && data.cFileName[size] != L'\0') size++; DA_INIT(result.files.values[n], size, alloc); @@ -445,12 +444,10 @@ kit_path_list_t kit_folder_enum(kit_str_t path, break; } - printf(" >> 5 \n"); fflush(stdout); for (i64 i = 0; i < size; i++) result.files.values[n].values[i] = data.cFileName[i]; } while (FindNextFileA(find, &data) != 0); - printf(" >> 6 \n"); fflush(stdout); FindClose(find); #else DIR *directory = opendir(buf); diff --git a/source/tests/file.test.c b/source/tests/file.test.c index c60c179..7a6224d 100644 --- a/source/tests/file.test.c +++ b/source/tests/file.test.c @@ -214,29 +214,21 @@ TEST("create folder") { } TEST("create folder recursive") { - printf(" 1 \n"); - fflush(stdout); REQUIRE_EQ(folder_create_recursive( SZ("test_folder" PATH_DELIM "foo" PATH_DELIM "bar")), KIT_OK); - printf(" 2 \n"); - fflush(stdout); REQUIRE_EQ(path_type(SZ("test_folder")), PATH_FOLDER); - printf(" 3 \n"); - fflush(stdout); REQUIRE_EQ(path_type(SZ("test_folder" PATH_DELIM "foo")), PATH_FOLDER); - printf(" 4 \n"); - fflush(stdout); REQUIRE_EQ( path_type(SZ("test_folder" PATH_DELIM "foo" PATH_DELIM "bar")), PATH_FOLDER); - printf(" 5 \n"); - fflush(stdout); REQUIRE_EQ(file_remove_recursive(SZ("test_folder"), NULL), KIT_OK); - printf(" 6 \n"); + printf(" 1 \n"); fflush(stdout); REQUIRE_EQ(path_type(SZ("test_folder")), PATH_NONE); + printf(" 2 \n"); + fflush(stdout); } TEST("file remove") { |