summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/kit/file.c16
-rw-r--r--source/kit/shared_mutex.h4
-rw-r--r--source/tests/file.test.c38
3 files changed, 35 insertions, 23 deletions
diff --git a/source/kit/file.c b/source/kit/file.c
index faeebcf..08f1888 100644
--- a/source/kit/file.c
+++ b/source/kit/file.c
@@ -251,14 +251,22 @@ kit_status_t kit_folder_create(kit_str_t path) {
}
kit_status_t kit_folder_create_recursive(kit_str_t path) {
- i64 i;
-
- for (i = 0;; i++) {
+ for (i32 i = 0;; i++) {
+ printf(" * %d * \n", i);
+ fflush(stdout);
+ printf(" * TAKE * \n");
+ fflush(stdout);
str_t part = kit_path_take(path, i);
- i32 type = kit_path_type(part);
+ printf(" * TYPE * \n");
+ fflush(stdout);
+ 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;
diff --git a/source/kit/shared_mutex.h b/source/kit/shared_mutex.h
index 13aae1b..0896b86 100644
--- a/source/kit/shared_mutex.h
+++ b/source/kit/shared_mutex.h
@@ -1,3 +1,7 @@
+// Shared mutex can be used in shared memory for interprocess
+// synchronization.
+//
+
#ifndef KIT_SHARED_MUTEX_H
#define KIT_SHARED_MUTEX_H
diff --git a/source/tests/file.test.c b/source/tests/file.test.c
index 86a88e2..9ec51bf 100644
--- a/source/tests/file.test.c
+++ b/source/tests/file.test.c
@@ -4,7 +4,7 @@
#define KIT_TEST_FILE file
#include "../kit/kit_test.h"
-TEST("file path cache") {
+TEST("path cache") {
str_builder_t user = path_user(NULL);
str_builder_t cache = path_cache(NULL);
@@ -30,7 +30,7 @@ TEST("file path cache") {
DA_DESTROY(expected);
}
-TEST("file path normalize one") {
+TEST("path normalize one") {
str_t foo = SZ("foo/bar/../baz");
str_t foo_norm = SZ("foo" PATH_DELIM "baz");
@@ -41,7 +41,7 @@ TEST("file path normalize one") {
DA_DESTROY(bar);
}
-TEST("file path normalize two") {
+TEST("path normalize two") {
str_t foo = SZ("foo/bar/../../baz");
str_t foo_norm = SZ("baz");
@@ -52,7 +52,7 @@ TEST("file path normalize two") {
DA_DESTROY(bar);
}
-TEST("file path normalize parent") {
+TEST("path normalize parent") {
str_t foo = SZ("../baz");
str_t foo_norm = SZ(".." PATH_DELIM "baz");
@@ -63,7 +63,7 @@ TEST("file path normalize parent") {
DA_DESTROY(bar);
}
-TEST("file path normalize double parent") {
+TEST("path normalize double parent") {
str_t foo = SZ("foo/../../baz");
str_t foo_norm = SZ(".." PATH_DELIM "baz");
@@ -74,7 +74,7 @@ TEST("file path normalize double parent") {
DA_DESTROY(bar);
}
-TEST("file path normalize windows delim") {
+TEST("path normalize windows delim") {
str_t foo = SZ("foo\\bar\\..\\baz");
str_t foo_norm = SZ("foo" PATH_DELIM "baz");
@@ -85,7 +85,7 @@ TEST("file path normalize windows delim") {
DA_DESTROY(bar);
}
-TEST("file path join no delim") {
+TEST("path join no delim") {
str_t foo = SZ("foo");
str_t bar = SZ("bar");
str_t joined = SZ("foo" PATH_DELIM "bar");
@@ -97,7 +97,7 @@ TEST("file path join no delim") {
DA_DESTROY(foobar);
}
-TEST("file path join delim left") {
+TEST("path join delim left") {
str_t foo = SZ("foo/");
str_t bar = SZ("bar");
str_t joined = SZ("foo" PATH_DELIM "bar");
@@ -109,7 +109,7 @@ TEST("file path join delim left") {
DA_DESTROY(foobar);
}
-TEST("file path join delim right") {
+TEST("join delim right") {
str_t foo = SZ("foo");
str_t bar = SZ("/bar");
str_t joined = SZ("foo" PATH_DELIM "bar");
@@ -121,7 +121,7 @@ TEST("file path join delim right") {
DA_DESTROY(foobar);
}
-TEST("file path join delim both") {
+TEST("path join delim both") {
str_t foo = SZ("foo/");
str_t bar = SZ("/bar");
str_t joined = SZ("foo" PATH_DELIM "bar");
@@ -133,7 +133,7 @@ TEST("file path join delim both") {
DA_DESTROY(foobar);
}
-TEST("file path user") {
+TEST("path user") {
str_builder_t user = path_user(NULL);
REQUIRE(user.size > 0);
@@ -141,7 +141,7 @@ TEST("file path user") {
DA_DESTROY(user);
}
-TEST("file path index relative") {
+TEST("path index relative") {
str_t foobar = SZ("foo/bar");
str_t foo = SZ("foo");
str_t bar = SZ("bar");
@@ -151,7 +151,7 @@ TEST("file path index relative") {
REQUIRE(path_index(foobar, 2).size == 0);
}
-TEST("file path index absolute") {
+TEST("path index absolute") {
str_t foobar = SZ("/foo/bar");
str_t foo = SZ("foo");
str_t bar = SZ("bar");
@@ -161,7 +161,7 @@ TEST("file path index absolute") {
REQUIRE(path_index(foobar, 2).size == 0);
}
-TEST("file path index windows disk name") {
+TEST("path index windows disk name") {
str_t foobar = SZ("c:\\foo\\bar");
str_t disk = SZ("c:");
str_t foo = SZ("foo");
@@ -173,7 +173,7 @@ TEST("file path index windows disk name") {
REQUIRE(path_index(foobar, 3).size == 0);
}
-TEST("file path take relative") {
+TEST("path take relative") {
str_t foobar = SZ("foo/bar/");
str_t foo = SZ("foo");
str_t bar = SZ("foo/bar");
@@ -184,7 +184,7 @@ TEST("file path take relative") {
REQUIRE(AR_EQUAL(path_take(foobar, 2), bar_end));
}
-TEST("file path take absolute") {
+TEST("path take absolute") {
str_t foobar = SZ("/foo/bar");
str_t foo = SZ("/foo");
str_t bar = SZ("/foo/bar");
@@ -193,7 +193,7 @@ TEST("file path take absolute") {
REQUIRE(AR_EQUAL(path_take(foobar, 1), bar));
}
-TEST("file path take windows disk name") {
+TEST("path take windows disk name") {
str_t foobar = SZ("c:\\foo\\bar");
str_t disk = SZ("c:");
str_t foo = SZ("c:\\foo");
@@ -204,7 +204,7 @@ TEST("file path take windows disk name") {
REQUIRE(AR_EQUAL(path_take(foobar, 2), bar));
}
-TEST("file create folder") {
+TEST("create folder") {
str_t folder_name = SZ("test_folder");
REQUIRE_EQ(folder_create(folder_name), KIT_OK);
@@ -213,7 +213,7 @@ TEST("file create folder") {
REQUIRE_EQ(path_type(folder_name), PATH_NONE);
}
-TEST("file create folder recursive") {
+TEST("create folder recursive") {
REQUIRE_EQ(folder_create_recursive(
SZ("test_folder" PATH_DELIM "foo" PATH_DELIM "bar")),
KIT_OK);