diff options
| author | Nicolas Hillegeer <nicolas@hillegeer.com> | 2014-07-14 21:17:39 +0200 |
|---|---|---|
| committer | Nicolas Hillegeer <nicolas@hillegeer.com> | 2014-07-14 21:17:39 +0200 |
| commit | 2b62dcddf801e096bde7d4608e090018b5227e98 (patch) | |
| tree | 728251b27edf7110565bc0c4c8cc5864f5b31bfe /src/nvim/os/fs.c | |
| parent | 47084ea7657121837536d409b9137fd38426aeef (diff) | |
| parent | 14239ae33128ae961a4ce9e68436ad3f0f557b90 (diff) | |
| download | rneovim-2b62dcddf801e096bde7d4608e090018b5227e98.tar.gz rneovim-2b62dcddf801e096bde7d4608e090018b5227e98.tar.bz2 rneovim-2b62dcddf801e096bde7d4608e090018b5227e98.zip | |
Merge #850 'impl mkdtemp for windows, refactor vim_tempname'
Diffstat (limited to 'src/nvim/os/fs.c')
| -rw-r--r-- | src/nvim/os/fs.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/nvim/os/fs.c b/src/nvim/os/fs.c index dce95eb3c9..46aea2bf36 100644 --- a/src/nvim/os/fs.c +++ b/src/nvim/os/fs.c @@ -3,6 +3,13 @@ #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/ascii.h" #include "nvim/memory.h" @@ -285,6 +292,21 @@ int os_mkdir(const char *path, int32_t mode) 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. /// /// @return `0` for success, non-zero for failure. |
