diff --git a/src/CHANGELOG b/src/CHANGELOG index 0cd13c84f..3246b5c83 100644 --- a/src/CHANGELOG +++ b/src/CHANGELOG @@ -160,6 +160,9 @@ ECL 1.0: - Now it should be possible to load the same FASL files multiple times, even if previous instances have not completely garbage collected. + - SI:MKSTEMP now works on Windows for more than 26 temporary file names + (Dustin Long) + * Unicode: - MAKE-STRING only allowed :ELEMENT-TYPE to be one of CHARACTER, BASE-CHAR, or diff --git a/src/c/unixfsys.d b/src/c/unixfsys.d index 139ed31e8..32d8a382f 100644 --- a/src/c/unixfsys.d +++ b/src/c/unixfsys.d @@ -792,6 +792,43 @@ si_mkstemp(cl_object template) cl_index l; int fd; +#if defined(mingw32) || defined(_MSC_VER) + + cl_object phys, dir, file; + char strTempDir[MAX_PATH]; + char strTempFileName[MAX_PATH]; + char * s; + + phys = cl_translate_logical_pathname(1, template); + + dir = cl_make_pathname(8, + @':type', Cnil, + @':name', Cnil, + @':version', Cnil, + @':defaults', phys); + + dir = cl_namestring(dir); + file = cl_file_namestring(phys); + + l = dir->base_string.fillp; + + memcpy(strTempDir, dir->base_string.self, l); + strTempDir[l] = 0; + for (s = strTempDir; *s; s++) + if (*s == '/') + *s = '\\'; + + if (!GetTempFileName(strTempDir, file->base_string.self, 0, strTempFileName)) + { + @(return Cnil) + } + + l = strlen(strTempFileName); + output = cl_alloc_simple_base_string(l); + memcpy(output->base_string.self, strTempFileName, l); + +#else + template = si_coerce_to_filename(template); l = template->base_string.fillp; output = cl_alloc_simple_base_string(l + 6); @@ -806,6 +843,9 @@ si_mkstemp(cl_object template) if (fd < 0) @(return Cnil) close(fd); + +#endif + @(return cl_truename(output)) }