LibC: Implemented mkstemp in stdlib

Implemented mkstemp method in stdlib.
This commit is contained in:
Brandon Scott 2019-11-16 04:34:20 -06:00 committed by Andreas Kling
commit bda36853c9
Notes: sideshowbarker 2024-07-19 11:12:03 +09:00
2 changed files with 12 additions and 0 deletions

View file

@ -382,6 +382,17 @@ char* mktemp(char* pattern)
return pattern;
}
int mkstemp(char* pattern)
{
char* path = mktemp(pattern);
int fd = open(path, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR); // I'm using the flags I saw glibc using.
if (fd >= 0)
return fd;
return -1;
}
char* mkdtemp(char* pattern)
{
int length = strlen(pattern);