diff options
author | Mitya Selivanov <automainint@guattari.tech> | 2024-02-11 18:17:33 +0100 |
---|---|---|
committer | Mitya Selivanov <automainint@guattari.tech> | 2024-02-11 18:17:33 +0100 |
commit | df00df5a7a5bcd9076d4423128ea014ab3535626 (patch) | |
tree | 337e62f8ca39b19b250b155a3fbeb495384e356b /source/kit/file.c | |
parent | 80da54bb97c279aa60fb77a9bbad9baa0f2e4477 (diff) | |
download | saw-df00df5a7a5bcd9076d4423128ea014ab3535626.zip |
Update kit
Diffstat (limited to 'source/kit/file.c')
-rw-r--r-- | source/kit/file.c | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/source/kit/file.c b/source/kit/file.c index e5b834f..76d3249 100644 --- a/source/kit/file.c +++ b/source/kit/file.c @@ -276,7 +276,7 @@ static void kit_prepare_path_(char *buf, kit_str_t path) { char buf[PATH_BUF_SIZE]; \ kit_prepare_path_(buf, path) -kit_status_t kit_folder_create(kit_str_t path) { +s32 kit_folder_create(kit_str_t path) { PREPARE_PATH_BUF_; #if defined(_WIN32) && !defined(__CYGWIN__) return CreateDirectoryA(buf, NULL) ? KIT_OK @@ -286,14 +286,14 @@ kit_status_t kit_folder_create(kit_str_t path) { #endif } -kit_status_t kit_folder_create_recursive(kit_str_t path) { +s32 kit_folder_create_recursive(kit_str_t path) { for (i32 i = 0;; i++) { str_t part = kit_path_take(path, i); i32 type = kit_path_type(part); if (type == KIT_PATH_FILE) return KIT_ERROR_FILE_ALREADY_EXISTS; if (type == KIT_PATH_NONE) { - kit_status_t s = kit_folder_create(part); + s32 s = kit_folder_create(part); if (s != KIT_OK) return s; } @@ -304,7 +304,7 @@ kit_status_t kit_folder_create_recursive(kit_str_t path) { return KIT_OK; } -kit_status_t kit_file_remove(kit_str_t path) { +s32 kit_file_remove(kit_str_t path) { PREPARE_PATH_BUF_; #if defined(_WIN32) && !defined(__CYGWIN__) return DeleteFileA(buf) ? KIT_OK : KIT_ERROR_UNLINK_FAILED; @@ -313,7 +313,7 @@ kit_status_t kit_file_remove(kit_str_t path) { #endif } -kit_status_t kit_folder_remove(kit_str_t path) { +s32 kit_folder_remove(kit_str_t path) { PREPARE_PATH_BUF_; #if defined(_WIN32) && !defined(__CYGWIN__) return RemoveDirectoryA(buf) ? KIT_OK : KIT_ERROR_RMDIR_FAILED; @@ -322,14 +322,14 @@ kit_status_t kit_folder_remove(kit_str_t path) { #endif } -kit_status_t kit_file_remove_recursive(kit_str_t path, - kit_allocator_t *alloc) { +s32 kit_file_remove_recursive(kit_str_t path, + kit_allocator_t *alloc) { i32 type = kit_path_type(path); i64 i; switch (type) { case KIT_PATH_FILE: { - kit_status_t s = kit_file_remove(path); + s32 s = kit_file_remove(path); assert(s == KIT_OK); return s; } @@ -346,15 +346,14 @@ kit_status_t kit_file_remove_recursive(kit_str_t path, for (i = 0; i < list.files.size; i++) { str_builder_t full_path = kit_path_join( path, WRAP_STR(list.files.values[i]), alloc); - kit_status_t s = kit_file_remove_recursive( - WRAP_STR(full_path), alloc); + s32 s = kit_file_remove_recursive(WRAP_STR(full_path), alloc); DA_DESTROY(full_path); assert(s == KIT_OK); } kit_path_list_destroy(list); - kit_status_t s = kit_folder_remove(path); + s32 s = kit_folder_remove(path); assert(s == KIT_OK); return s; } @@ -652,13 +651,13 @@ kit_mapped_file_t kit_file_map(kit_str_t path, i64 size, i32 mode) { return mf; } -kit_status_t kit_file_sync(kit_mapped_file_t *mf) { +s32 kit_file_sync(kit_mapped_file_t *mf) { assert(mf != NULL); if (mf == NULL) return KIT_ERROR_INVALID_ARGUMENT; - kit_status_t status = KIT_OK; + s32 status = KIT_OK; #if !defined(_WIN32) || defined(__CYGWIN__) if (msync(mf->bytes, mf->size, MS_SYNC) != 0) @@ -668,13 +667,13 @@ kit_status_t kit_file_sync(kit_mapped_file_t *mf) { return status; } -kit_status_t kit_file_unmap(kit_mapped_file_t *mf) { +s32 kit_file_unmap(kit_mapped_file_t *mf) { assert(mf != NULL); if (mf == NULL) return KIT_ERROR_INVALID_ARGUMENT; - kit_status_t status = KIT_OK; + s32 status = KIT_OK; #if defined(_WIN32) && !defined(__CYGWIN__) if (!UnmapViewOfFile(mf->bytes)) |