mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-04 06:38:47 +00:00
Narrow fullpath_mutex usage
This commit is contained in:
@@ -937,16 +937,20 @@ gb_global BlockingMutex fullpath_mutex;
|
|||||||
#if defined(GB_SYSTEM_WINDOWS)
|
#if defined(GB_SYSTEM_WINDOWS)
|
||||||
gb_internal String path_to_fullpath(gbAllocator a, String s) {
|
gb_internal String path_to_fullpath(gbAllocator a, String s) {
|
||||||
String result = {};
|
String result = {};
|
||||||
mutex_lock(&fullpath_mutex);
|
|
||||||
defer (mutex_unlock(&fullpath_mutex));
|
|
||||||
|
|
||||||
String16 string16 = string_to_string16(heap_allocator(), s);
|
String16 string16 = string_to_string16(heap_allocator(), s);
|
||||||
defer (gb_free(heap_allocator(), string16.text));
|
defer (gb_free(heap_allocator(), string16.text));
|
||||||
|
|
||||||
DWORD len = GetFullPathNameW(&string16[0], 0, nullptr, nullptr);
|
DWORD len;
|
||||||
|
|
||||||
|
mutex_lock(&fullpath_mutex);
|
||||||
|
|
||||||
|
len = GetFullPathNameW(&string16[0], 0, nullptr, nullptr);
|
||||||
if (len != 0) {
|
if (len != 0) {
|
||||||
wchar_t *text = gb_alloc_array(permanent_allocator(), wchar_t, len+1);
|
wchar_t *text = gb_alloc_array(permanent_allocator(), wchar_t, len+1);
|
||||||
GetFullPathNameW(&string16[0], len, text, nullptr);
|
GetFullPathNameW(&string16[0], len, text, nullptr);
|
||||||
|
mutex_unlock(&fullpath_mutex);
|
||||||
|
|
||||||
text[len] = 0;
|
text[len] = 0;
|
||||||
result = string16_to_string(a, make_string16(text, len));
|
result = string16_to_string(a, make_string16(text, len));
|
||||||
result = string_trim_whitespace(result);
|
result = string_trim_whitespace(result);
|
||||||
@@ -957,6 +961,8 @@ gb_internal String path_to_fullpath(gbAllocator a, String s) {
|
|||||||
result.text[i] = '/';
|
result.text[i] = '/';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
mutex_unlock(&fullpath_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
Reference in New Issue
Block a user