aboutsummaryrefslogtreecommitdiff
path: root/src/path.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2023-01-04 15:15:12 +0000
committergingerBill <bill@gingerbill.org>2023-01-04 15:15:12 +0000
commitfaa735d0c745ddc0b550e2a54f10588c873841b7 (patch)
tree1e61f7f70aa130c77c2b42de9cba60de6c09c35f /src/path.cpp
parentd4e18109da5fa051d689be84a6ecf1e77348c74e (diff)
Localize gen_types mutexes
Diffstat (limited to 'src/path.cpp')
-rw-r--r--src/path.cpp12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/path.cpp b/src/path.cpp
index 500a40cc2..4b426fc87 100644
--- a/src/path.cpp
+++ b/src/path.cpp
@@ -222,7 +222,6 @@ gb_internal i64 get_file_size(String path) {
gb_internal ReadDirectoryError read_directory(String path, Array<FileInfo> *fi) {
GB_ASSERT(fi != nullptr);
- gbAllocator a = heap_allocator();
while (path.len > 0) {
Rune end = path[path.len-1];
@@ -239,9 +238,7 @@ gb_internal ReadDirectoryError read_directory(String path, Array<FileInfo> *fi)
return ReadDirectory_InvalidPath;
}
{
- char *c_str = alloc_cstring(a, path);
- defer (gb_free(a, c_str));
-
+ char *c_str = alloc_cstring(temporary_allocator(), path);
gbFile f = {};
gbFileError file_err = gb_file_open(&f, c_str);
defer (gb_file_close(&f));
@@ -258,6 +255,7 @@ gb_internal ReadDirectoryError read_directory(String path, Array<FileInfo> *fi)
}
+ gbAllocator a = heap_allocator();
char *new_path = gb_alloc_array(a, char, path.len+3);
defer (gb_free(a, new_path));
@@ -280,8 +278,8 @@ gb_internal ReadDirectoryError read_directory(String path, Array<FileInfo> *fi)
do {
wchar_t *filename_w = file_data.cFileName;
- i64 size = cast(i64)file_data.nFileSizeLow;
- size |= (cast(i64)file_data.nFileSizeHigh) << 32;
+ u64 size = cast(u64)file_data.nFileSizeLow;
+ size |= (cast(u64)file_data.nFileSizeHigh) << 32;
String name = string16_to_string(a, make_string16_c(filename_w));
if (name == "." || name == "..") {
gb_free(a, name.text);
@@ -299,7 +297,7 @@ gb_internal ReadDirectoryError read_directory(String path, Array<FileInfo> *fi)
FileInfo info = {};
info.name = name;
info.fullpath = path_to_full_path(a, filepath);
- info.size = size;
+ info.size = cast(i64)size;
info.is_dir = (file_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
array_add(fi, info);
} while (FindNextFileW(find_file, &file_data));