Add libc mktemp and tempnam. Update test.

This commit is contained in:
Christoffer Lerno
2026-02-07 20:25:28 +01:00
parent 02a67254cc
commit 89b9f52f1e
3 changed files with 11 additions and 2 deletions

View File

@@ -5,7 +5,11 @@ tlocal char[1024] buf;
fn String random_name()
{
return libc::tmpnam(&buf).str_view();
ZString str = libc::tempnam(null, "randfile_");
String s = str.str_view();
buf[:s.len] = s[..];
libc::free(str);
return (String)buf[:s.len];
}
fn void map_read_only() @test

View File

@@ -58,7 +58,10 @@ fn void read_write_any()
data.hello = 0xCC;
char[1024] buf;
String name = libc::tmpnam(&buf).str_view();
ZString zname = libc::tempnam(null, "testfile_");
defer libc::free(zname);
String name = zname.str_view();
File file = file::open(name, "wb")!!;
io::write_any(&file, &data)!!;