summaryrefslogtreecommitdiff
path: root/src/fileio.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2015-03-31 13:33:08 +0200
committerBram Moolenaar <Bram@vim.org>2015-03-31 13:33:08 +0200
commite5c421cfd70a4d864faa0fac4e9f2dd6cdf5881d (patch)
tree77b845e567cd28c87bf4e9226384cccf04ab645b /src/fileio.c
parent1ca2e361a869c58a775b5fabb2aaf4e2675ea7ba (diff)
downloadvim-git-e5c421cfd70a4d864faa0fac4e9f2dd6cdf5881d.tar.gz
updated for version 7.4.684v7.4.684
Problem: When starting several Vim instances in diff mode, the temp files used may not be unique. (Issue 353) Solution: Add an argument to vim_tempname() to keep the file.
Diffstat (limited to 'src/fileio.c')
-rw-r--r--src/fileio.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/fileio.c b/src/fileio.c
index 388446a48..9965920c5 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -2872,7 +2872,7 @@ readfile_charconvert(fname, fenc, fdp)
char_u *tmpname;
char_u *errmsg = NULL;
- tmpname = vim_tempname('r');
+ tmpname = vim_tempname('r', FALSE);
if (tmpname == NULL)
errmsg = (char_u *)_("Can't find temp file for conversion");
else
@@ -4288,7 +4288,7 @@ buf_write(buf, fname, sfname, start, end, eap, append, forceit,
*/
if (*p_ccv != NUL)
{
- wfname = vim_tempname('w');
+ wfname = vim_tempname('w', FALSE);
if (wfname == NULL) /* Can't write without a tempfile! */
{
errmsg = (char_u *)_("E214: Can't find temp file for writing");
@@ -7344,14 +7344,16 @@ vim_settempdir(tempdir)
/*
* vim_tempname(): Return a unique name that can be used for a temp file.
*
- * The temp file is NOT created.
+ * The temp file is NOT garanteed to be created. If "keep" is FALSE it is
+ * garanteed to NOT be created.
*
* The returned pointer is to allocated memory.
* The returned pointer is NULL if no valid name was found.
*/
char_u *
-vim_tempname(extra_char)
+vim_tempname(extra_char, keep)
int extra_char UNUSED; /* char to use in the name instead of '?' */
+ int keep UNUSED;
{
#ifdef USE_TMPNAM
char_u itmp[L_tmpnam]; /* use tmpnam() */
@@ -7487,8 +7489,9 @@ vim_tempname(extra_char)
buf4[2] = extra_char; /* make it "VIa", "VIb", etc. */
if (GetTempFileName(szTempFile, buf4, 0, itmp) == 0)
return NULL;
- /* GetTempFileName() will create the file, we don't want that */
- (void)DeleteFile(itmp);
+ if (!keep)
+ /* GetTempFileName() will create the file, we don't want that */
+ (void)DeleteFile(itmp);
/* Backslashes in a temp file name cause problems when filtering with
* "sh". NOTE: This also checks 'shellcmdflag' to help those people who