std/io/os/temp_directory.c3: fix INVALID_PATH in Win32 native_temp_directory (#2762)

* std/io/os/temp_directory.c3: fix INVALID_PATH in Windows native_temp_directory

- Use the actual length from GetTempPathW for Windows temp path slice
- We can remove the workaround in the test_suite_runner for WIN32 and
create all directories in %temp% now

* Updated releasenotes.

---------

Co-authored-by: Christoffer Lerno <christoffer@aegik.com>
This commit is contained in:
Manu Linares
2026-01-15 17:23:30 -03:00
committed by GitHub
parent 8a1c02c840
commit f254c27966
3 changed files with 6 additions and 8 deletions

View File

@@ -122,9 +122,10 @@ fn Path? native_temp_directory(Allocator allocator) @if(env::WIN32) => @pool()
{
Win32_DWORD len = win32::getTempPathW(0, null);
if (!len) return io::GENERAL_ERROR?;
Char16[] buff = mem::talloc_array(Char16, len + (usz)1);
if (!win32::getTempPathW(len, buff)) return io::GENERAL_ERROR?;
return path::new(allocator, string::tfrom_utf16(buff[:len]));
Char16[] buff = mem::talloc_array(Char16, len);
Win32_DWORD res = win32::getTempPathW(len, buff);
if (!res) return io::GENERAL_ERROR?;
return path::new(allocator, string::tfrom_utf16(buff[:res]));
}
module std::io::os @if(env::NO_LIBC);

View File

@@ -60,6 +60,7 @@
- bitorder::read and bitorder::write may fail because of unaligned access #2734.
- Fix `LinkedList.to_format` to properly iterate linked list for printing.
- Hashing a vector would not use the entire vector in some cases.
- Fix to `temp_directory` on Windows #2762.
### Stdlib changes
- Add `ThreadPool` join function to wait for all threads to finish in the pool without destroying the threads.

View File

@@ -704,11 +704,7 @@ fn int main(String[] args)
context.start_cwd = path::tcwd()!!;
context.print_mutex.init()!!;
$if env::WIN32:
context.test_root = context.start_cwd;
$else
context.test_root = path::temp_directory(mem)!!;
$endif
context.test_root = path::temp_directory(mem)!!;
Path? path = args[1].to_tpath();
if (catch path) arg_error_exit(appname, "Invalid compiler path: %s", args[1]);