summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Libraries/LibC/stdlib.cpp11
-rw-r--r--Libraries/LibC/stdlib.h1
2 files changed, 12 insertions, 0 deletions
diff --git a/Libraries/LibC/stdlib.cpp b/Libraries/LibC/stdlib.cpp
index fee9604642..b4d2a97fa4 100644
--- a/Libraries/LibC/stdlib.cpp
+++ b/Libraries/LibC/stdlib.cpp
@@ -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);
diff --git a/Libraries/LibC/stdlib.h b/Libraries/LibC/stdlib.h
index 3cf039abdc..529d4a99b7 100644
--- a/Libraries/LibC/stdlib.h
+++ b/Libraries/LibC/stdlib.h
@@ -41,6 +41,7 @@ long labs(long);
double atof(const char*);
int system(const char* command);
char* mktemp(char*);
+int mkstemp(char*);
char* mkdtemp(char*);
void* bsearch(const void* key, const void* base, size_t nmemb, size_t size, int (*compar)(const void*, const void*));
size_t mbstowcs(wchar_t*, const char*, size_t);