mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Temporary os_mkdtemp implementation. Use it instead of mkdtemp.
This commit is contained in:
parent
47084ea765
commit
8b91ba929b
@ -5254,7 +5254,7 @@ vim_tempname (
|
|||||||
# ifdef HAVE_MKDTEMP
|
# ifdef HAVE_MKDTEMP
|
||||||
/* Leave room for filename */
|
/* Leave room for filename */
|
||||||
STRCAT(itmp, "vXXXXXX");
|
STRCAT(itmp, "vXXXXXX");
|
||||||
if (mkdtemp((char *)itmp) != NULL)
|
if (os_mkdtemp((char *)itmp) != NULL)
|
||||||
vim_settempdir(itmp);
|
vim_settempdir(itmp);
|
||||||
# else
|
# else
|
||||||
/* Get an arbitrary number of up to 6 digits. When it's
|
/* Get an arbitrary number of up to 6 digits. When it's
|
||||||
|
@ -3,6 +3,13 @@
|
|||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
|
// TODO(hinidu): remove after implementing `os_mkdtemp` on top of libuv
|
||||||
|
#ifdef WIN32
|
||||||
|
# include <io.h>
|
||||||
|
#else
|
||||||
|
# include <stdlib.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "nvim/os/os.h"
|
#include "nvim/os/os.h"
|
||||||
#include "nvim/ascii.h"
|
#include "nvim/ascii.h"
|
||||||
#include "nvim/memory.h"
|
#include "nvim/memory.h"
|
||||||
@ -285,6 +292,21 @@ int os_mkdir(const char *path, int32_t mode)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Create a unique temporary directory.
|
||||||
|
/// TODO(hinidu): Implement on top of libuv. ref #850
|
||||||
|
///
|
||||||
|
/// @param[in,out] template Template of the path to the directory with XXXXXX
|
||||||
|
/// which would be replaced by random chars.
|
||||||
|
/// @return Pointer to changed `template` for success, `NULL` for failure.
|
||||||
|
char *os_mkdtemp(char *template)
|
||||||
|
{
|
||||||
|
#ifdef WIN32
|
||||||
|
return _mktemp(template) && os_mkdir(template, 0700) == 0 ? template : NULL;
|
||||||
|
#else
|
||||||
|
return mkdtemp(template);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
/// Remove a directory.
|
/// Remove a directory.
|
||||||
///
|
///
|
||||||
/// @return `0` for success, non-zero for failure.
|
/// @return `0` for success, non-zero for failure.
|
||||||
|
Loading…
Reference in New Issue
Block a user