mirror of
https://gitlab.com/embeddable-common-lisp/ecl.git
synced 2026-01-01 07:10:34 -08:00
SI:MKSTEMP implemented for Windows (D. Long)
This commit is contained in:
parent
8219dde991
commit
ba3bbc2953
2 changed files with 43 additions and 0 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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))
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue