Browse Source

Unify tmp file creation

master
Arun Prakash Jana 6 years ago
parent
commit
b41560572c
No known key found for this signature in database GPG Key ID: A75979F35C080412
1 changed files with 9 additions and 9 deletions
  1. +9
    -9
      src/nnn.c

+ 9
- 9
src/nnn.c View File

@@ -731,6 +731,12 @@ static char *xbasename(char *path)
return base ? base + 1 : path; return base ? base + 1 : path;
} }


static int create_tmp_file()
{
xstrlcpy(g_tmpfpath + g_tmpfplen - 1, messages[STR_TMPFILE], TMP_LEN_MAX - g_tmpfplen);
return mkstemp(g_tmpfpath);
}

/* Writes buflen char(s) from buf to a file */ /* Writes buflen char(s) from buf to a file */
static void writecp(const char *buf, const size_t buflen) static void writecp(const char *buf, const size_t buflen)
{ {
@@ -792,9 +798,7 @@ static void showcplist(void)
if (!copybufpos) if (!copybufpos)
return; return;


xstrlcpy(g_tmpfpath + g_tmpfplen - 1, messages[STR_TMPFILE], TMP_LEN_MAX - g_tmpfplen); fd = create_tmp_file();

fd = mkstemp(g_tmpfpath);
if (fd == -1) { if (fd == -1) {
DPRINTF_S("mkstemp failed!"); DPRINTF_S("mkstemp failed!");
return; return;
@@ -2312,9 +2316,7 @@ static bool show_stats(const char *fpath, const char *fname, const struct stat *
size_t r; size_t r;
FILE *fp; FILE *fp;


xstrlcpy(g_tmpfpath + g_tmpfplen - 1, messages[STR_TMPFILE], TMP_LEN_MAX - g_tmpfplen); fd = create_tmp_file();

fd = mkstemp(g_tmpfpath);
if (fd == -1) if (fd == -1)
return FALSE; return FALSE;


@@ -2567,9 +2569,7 @@ static bool show_help(const char *path)
"cc SSHFS mount u Unmount\n" "cc SSHFS mount u Unmount\n"
"b^P Prompt ^N Note = Launcher\n"}; "b^P Prompt ^N Note = Launcher\n"};


xstrlcpy(g_tmpfpath + g_tmpfplen - 1, messages[STR_TMPFILE], TMP_LEN_MAX - g_tmpfplen); fd = create_tmp_file();

fd = mkstemp(g_tmpfpath);
if (fd == -1) if (fd == -1)
return FALSE; return FALSE;




||||||
x
 
000:0
Loading…
Cancel
Save