mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:07:47 +00:00
LibC: Implement tmpfile()
This commit is contained in:
parent
f6bd4f8691
commit
bbf878e987
1 changed files with 12 additions and 2 deletions
|
@ -635,7 +635,17 @@ void funlockfile(FILE* filehandle)
|
||||||
|
|
||||||
FILE* tmpfile()
|
FILE* tmpfile()
|
||||||
{
|
{
|
||||||
dbgprintf("FIXME: Implement tmpfile()\n");
|
char tmp_path[] = "/tmp/XXXXXX";
|
||||||
ASSERT_NOT_REACHED();
|
if (!__generate_unique_filename(tmp_path))
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
int fd = open(tmp_path, O_CREAT | O_EXCL | O_RDWR, S_IWUSR | S_IRUSR);
|
||||||
|
if (fd < 0)
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
// FIXME: instead of using this hack, implement with O_TMPFILE or similar
|
||||||
|
unlink(tmp_path);
|
||||||
|
|
||||||
|
return make_FILE(fd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue