summaryrefslogtreecommitdiff
path: root/src/w32.c
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2017-08-12 11:29:37 +0300
committerEli Zaretskii <eliz@gnu.org>2017-08-12 11:29:37 +0300
commit8cc8ad02bd5c410c61680735149ce7caf67f088d (patch)
treef99ec13f9647acb1bdc89a2691943fa1802b9d33 /src/w32.c
parent84288cf4211a4490c0155d3c0022617b92294f49 (diff)
downloademacs-8cc8ad02bd5c410c61680735149ce7caf67f088d.tar.gz
Use Gnulib 'tempname' on MS-Windows
* lib-src/ntlib.h (mkdir, open): Remove redefinitions. They are now in nt/inc/ms-w32.h. * lib-src/ntlib.c (sys_mkdir, sys_open): New functions. (mkostemp): Remove. * src/w32.c (mkostemp): Remove. (sys_mkdir): Accept a second (unused) argument. * src/fileio.c (Fmake_directory_internal): Remove the WINDOWSNT specific call to mkdir. (Bug#28023) * nt/inc/ms-w32.h (mkdir): Remove from "#ifdef emacs" and redefine to accept 2 arguments. (open): Remove from "#ifdef emacs". * nt/mingw-cfg.site (ac_cv_func_mkostemp): Remove. * nt/gnulib-cfg.mk (OMIT_GNULIB_MODULE_mkostemp) (OMIT_GNULIB_MODULE_tempname): Remove.
Diffstat (limited to 'src/w32.c')
-rw-r--r--src/w32.c58
1 files changed, 1 insertions, 57 deletions
diff --git a/src/w32.c b/src/w32.c
index fa3cbe183fb..bdeaed0675b 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -74,7 +74,6 @@ char *sys_ctime (const time_t *);
int sys_chdir (const char *);
int sys_creat (const char *, int);
FILE *sys_fopen (const char *, const char *);
-int sys_mkdir (const char *);
int sys_open (const char *, int, int);
int sys_rename (char const *, char const *);
int sys_rmdir (const char *);
@@ -4344,7 +4343,7 @@ sys_link (const char * old, const char * new)
}
int
-sys_mkdir (const char * path)
+sys_mkdir (const char * path, mode_t mode)
{
path = map_w32_filename (path, NULL);
@@ -4397,61 +4396,6 @@ sys_open (const char * path, int oflag, int mode)
return res;
}
-/* Implementation of mkostemp for MS-Windows, to avoid race conditions
- when using mktemp.
-
- Standard algorithm for generating a temporary file name seems to be
- use pid or tid with a letter on the front (in place of the 6 X's)
- and cycle through the letters to find a unique name. We extend
- that to allow any reasonable character as the first of the 6 X's,
- so that the number of simultaneously used temporary files will be
- greater. */
-
-int
-mkostemp (char * template, int flags)
-{
- char * p;
- int i, fd = -1;
- unsigned uid = GetCurrentThreadId ();
- int save_errno = errno;
- static char first_char[] = "abcdefghijklmnopqrstuvwyz0123456789!%-_@#";
-
- errno = EINVAL;
- if (template == NULL)
- return -1;
-
- p = template + strlen (template);
- i = 5;
- /* replace up to the last 5 X's with uid in decimal */
- while (--p >= template && p[0] == 'X' && --i >= 0)
- {
- p[0] = '0' + uid % 10;
- uid /= 10;
- }
-
- if (i < 0 && p[0] == 'X')
- {
- i = 0;
- do
- {
- p[0] = first_char[i];
- if ((fd = sys_open (template,
- flags | _O_CREAT | _O_EXCL | _O_RDWR,
- S_IRUSR | S_IWUSR)) >= 0
- || errno != EEXIST)
- {
- if (fd >= 0)
- errno = save_errno;
- return fd;
- }
- }
- while (++i < sizeof (first_char));
- }
-
- /* Template is badly formed or else we can't generate a unique name. */
- return -1;
-}
-
int
fchmod (int fd, mode_t mode)
{