mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 20:15:17 +00:00
LibC: Implement tmpfile()
This commit is contained in:
parent
f6bd4f8691
commit
bbf878e987
Notes:
sideshowbarker
2024-07-19 10:39:47 +09:00
Author: https://github.com/shannonbooth Commit: https://github.com/SerenityOS/serenity/commit/bbf878e9876 Pull-request: https://github.com/SerenityOS/serenity/pull/917 Reviewed-by: https://github.com/awesomekling ✅
1 changed files with 12 additions and 2 deletions
|
@ -635,7 +635,17 @@ void funlockfile(FILE* filehandle)
|
|||
|
||||
FILE* tmpfile()
|
||||
{
|
||||
dbgprintf("FIXME: Implement tmpfile()\n");
|
||||
ASSERT_NOT_REACHED();
|
||||
char tmp_path[] = "/tmp/XXXXXX";
|
||||
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
Reference in a new issue