summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMitya Selivanov <automainint@guattari.tech>2023-09-15 22:43:14 +0200
committerMitya Selivanov <automainint@guattari.tech>2023-09-15 22:43:14 +0200
commit69307df84f0084f5c45f59fefba51f4de9d331d7 (patch)
treef578f7f37f5fae81bae461f0f5a24420a9db4c93
parent61eb138424df83d3e8f168836b1efec63d832b1a (diff)
downloadkit-69307df84f0084f5c45f59fefba51f4de9d331d7.zip
test
-rw-r--r--source/kit/file.c20
-rw-r--r--source/tests/file.test.c12
2 files changed, 21 insertions, 11 deletions
diff --git a/source/kit/file.c b/source/kit/file.c
index 08f1888..df94d59 100644
--- a/source/kit/file.c
+++ b/source/kit/file.c
@@ -252,21 +252,11 @@ kit_status_t kit_folder_create(kit_str_t path) {
kit_status_t kit_folder_create_recursive(kit_str_t path) {
for (i32 i = 0;; i++) {
- printf(" * %d * \n", i);
- fflush(stdout);
- printf(" * TAKE * \n");
- fflush(stdout);
str_t part = kit_path_take(path, i);
- printf(" * TYPE * \n");
- fflush(stdout);
- i32 type = kit_path_type(part);
+ i32 type = kit_path_type(part);
if (type == KIT_PATH_FILE)
return KIT_ERROR_FILE_ALREADY_EXISTS;
if (type == KIT_PATH_NONE) {
- printf(" * CREATE * \n");
- fflush(stdout);
- printf(" \"%s\" \n", BS(part));
- fflush(stdout);
kit_status_t s = kit_folder_create(part);
if (s != KIT_OK)
return s;
@@ -423,15 +413,20 @@ 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);
@@ -440,6 +435,7 @@ 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);
@@ -449,10 +445,12 @@ 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 9ec51bf..c60c179 100644
--- a/source/tests/file.test.c
+++ b/source/tests/file.test.c
@@ -214,16 +214,28 @@ 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");
+ fflush(stdout);
REQUIRE_EQ(path_type(SZ("test_folder")), PATH_NONE);
}