summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/misc/util/utilFile.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/misc/util/utilFile.c b/src/misc/util/utilFile.c
index 4bb2f4c6..b6835daa 100644
--- a/src/misc/util/utilFile.c
+++ b/src/misc/util/utilFile.c
@@ -102,6 +102,17 @@ int tmpFile(const char* prefix, const char* suffix, char** out_name)
}
assert(0); // -- could not open temporary file
return 0;
+#elif defined(__wasm)
+ static int seq = 0; // no risk of collision since we're in a sandbox
+ int fd;
+ *out_name = (char*)malloc(strlen(prefix) + strlen(suffix) + 9);
+ sprintf(*out_name, "%s%08d%s", prefix, seq++, suffix);
+ fd = open(*out_name, O_CREAT | O_EXCL | O_RDWR, S_IREAD | S_IWRITE);
+ if (fd == -1){
+ free(*out_name);
+ *out_name = NULL;
+ }
+ return fd;
#else
int fd;
*out_name = (char*)malloc(strlen(prefix) + strlen(suffix) + 7);