aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTetralux <tetraluxonpc@gmail.com>2024-02-12 06:00:49 +0000
committerTetralux <tetraluxonpc@gmail.com>2024-02-12 06:03:51 +0000
commitd6734c85b8c58e035d01e8a6ed60f8fae50cf1de (patch)
treeca5924bbbe1f7fb11aff6828ee487eabb4a17db2
parentcec08114fdd9812819c10c66cd10f0a9d63866b2 (diff)
[os] Fix os.change_directory(), os.set_current_directory()
- set_current_directory() was leaking the wstring path string because it wasn't using the temp allocator. - change_directory() wasn't calling SetCurrentDirectoryW() under the lock!
-rw-r--r--core/os/file_windows.odin16
1 files changed, 3 insertions, 13 deletions
diff --git a/core/os/file_windows.odin b/core/os/file_windows.odin
index 831e9c38c..3efe30d17 100644
--- a/core/os/file_windows.odin
+++ b/core/os/file_windows.odin
@@ -394,7 +394,8 @@ get_current_directory :: proc(allocator := context.allocator) -> string {
}
set_current_directory :: proc(path: string) -> (err: Errno) {
- wstr := win32.utf8_to_wstring(path)
+ runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD()
+ wstr := win32.utf8_to_wstring(path, context.temp_allocator)
win32.AcquireSRWLockExclusive(&cwd_lock)
@@ -406,18 +407,7 @@ set_current_directory :: proc(path: string) -> (err: Errno) {
return
}
-
-
-
-change_directory :: proc(path: string) -> (err: Errno) {
- runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD()
- wpath := win32.utf8_to_wstring(path, context.temp_allocator)
-
- if !win32.SetCurrentDirectoryW(wpath) {
- err = Errno(win32.GetLastError())
- }
- return
-}
+change_directory :: set_current_directory
make_directory :: proc(path: string, mode: u32 = 0) -> (err: Errno) {
runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD()