aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/fileio.c
diff options
context:
space:
mode:
authorPavel Platto <hinidu@gmail.com>2014-06-19 00:58:04 +0300
committerNicolas Hillegeer <nicolas@hillegeer.com>2014-07-14 21:14:39 +0200
commitedd7a8c5ddd99bd0c02b4218d43bccb562809d55 (patch)
tree764a6762ee492e3589c209fd1d34559addcc70ab /src/nvim/fileio.c
parented10eb6fa92989d5a3841bf225a38b524c910e2e (diff)
downloadrneovim-edd7a8c5ddd99bd0c02b4218d43bccb562809d55.tar.gz
rneovim-edd7a8c5ddd99bd0c02b4218d43bccb562809d55.tar.bz2
rneovim-edd7a8c5ddd99bd0c02b4218d43bccb562809d55.zip
Remove #ifdefs TEMPDIRNAMES and add TEMPDIRNAMES for Windows
Vim does not define TEMPDIRNAMES for all systems, but it is defined for all systems supported by Neovim. Temporary directory names for Windows was obtained from GetTempPath() function documentation at MSDN. Additionally small renamings were performed.
Diffstat (limited to 'src/nvim/fileio.c')
-rw-r--r--src/nvim/fileio.c29
1 files changed, 5 insertions, 24 deletions
diff --git a/src/nvim/fileio.c b/src/nvim/fileio.c
index e9a1545846..8dcc066258 100644
--- a/src/nvim/fileio.c
+++ b/src/nvim/fileio.c
@@ -5156,7 +5156,6 @@ void write_lnum_adjust(linenr_T offset)
curbuf->b_no_eol_lnum += offset;
}
-#if defined(TEMPDIRNAMES) || defined(PROTO)
static long temp_count = 0; /* Temp filename counter. */
/*
@@ -5184,9 +5183,6 @@ void vim_deltempdir(void)
}
}
-#endif
-
-#ifdef TEMPDIRNAMES
/*
* Directory "tempdir" was created. Expand this name to a full path and put
* it in "vim_tempdir". This avoids that using ":cd" would confuse us.
@@ -5203,7 +5199,6 @@ static void vim_settempdir(char_u *tempdir)
free(buf);
}
}
-#endif
/*
* vim_tempname(): Return a unique name that can be used for a temp file.
@@ -5218,10 +5213,9 @@ vim_tempname (
int extra_char /* char to use in the name instead of '?' */
)
{
- char_u itmp[TEMPNAMELEN];
+ char_u itmp[TEMP_FILE_PATH_MAXLEN];
-#ifdef TEMPDIRNAMES
- static char *(tempdirs[]) = {TEMPDIRNAMES};
+ static const char *temp_dirs[] = TEMP_DIR_NAMES;
int i;
/*
@@ -5233,11 +5227,11 @@ vim_tempname (
*/
if (vim_tempdir == NULL) {
/*
- * Try the entries in TEMPDIRNAMES to create the temp directory.
+ * Try the entries in `TEMP_DIR_NAMES` to create the temp directory.
*/
- for (i = 0; i < (int)(sizeof(tempdirs) / sizeof(char *)); ++i) {
+ for (i = 0; i < (int)(sizeof(temp_dirs) / sizeof(char *)); ++i) {
/* expand $TMP, leave room for "/v1100000/999999999" */
- expand_env((char_u *)tempdirs[i], itmp, TEMPNAMELEN - 20);
+ expand_env((char_u *)temp_dirs[i], itmp, TEMP_FILE_PATH_MAXLEN - 20);
if (os_isdir(itmp)) { /* directory exists */
add_pathsep(itmp);
@@ -5259,19 +5253,6 @@ vim_tempname (
}
return NULL;
-
-#else /* TEMPDIRNAMES */
-
- char_u *p;
-
- STRCPY(itmp, TEMPNAME);
- if ((p = vim_strchr(itmp, '?')) != NULL)
- *p = extra_char;
- if (mktemp((char *)itmp) == NULL)
- return NULL;
-
- return vim_strsave(itmp);
-#endif /* TEMPDIRNAMES */
}
#if defined(BACKSLASH_IN_FILENAME) || defined(PROTO)