mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 03:51:18 +00:00
Add libc mktemp and tempnam. Update test.
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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)!!;
|
||||
|
||||
Reference in New Issue
Block a user