netstar pushed a commit to branch master.

http://git.enlightenment.org/tools/edi.git/commit/?id=3ec3d476fde66d39d188dba9917d9da3b73b3c65

commit 3ec3d476fde66d39d188dba9917d9da3b73b3c65
Author: Al Poole <nets...@gmail.com>
Date:   Sat Oct 21 14:05:13 2017 +0100

    edi_file: replace. use a local temp directory rather than /tmp.
    
    This is firstly more portable and also some distrbutors won't allow
    us to move from /tmp (wise).
---
 src/bin/edi_file.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/bin/edi_file.c b/src/bin/edi_file.c
index a67e79e..4c94928 100644
--- a/src/bin/edi_file.c
+++ b/src/bin/edi_file.c
@@ -1,5 +1,6 @@
 #include "Edi.h"
 #include "edi_file.h"
+#include "edi_config.h"
 #include "edi_private.h"
 
 Eina_Bool
@@ -23,10 +24,14 @@ edi_file_text_replace(const char *path, const char *search, 
const char *replace)
    char *map, *found;
    FILE *tempfile;
    Eina_File *f;
-   char tempfilepath[PATH_MAX];
+   char *tempfiledir, *tempfilepath;
    unsigned long long len, idx;
    unsigned int slen;
 
+   tempfiledir = edi_path_append(_edi_config_dir_get(), ".tmp");
+
+   ecore_file_mkdir(tempfiledir);
+
    f = eina_file_open(path, EINA_FALSE);
    if (!f) return;
 
@@ -44,7 +49,7 @@ edi_file_text_replace(const char *path, const char *search, 
const char *replace)
         return;
      }
 
-   snprintf(tempfilepath, sizeof(tempfilepath), "/tmp/%s.tmp", 
ecore_file_file_get(path));
+   tempfilepath = edi_path_append(tempfiledir, ecore_file_file_get(path));
 
    tempfile = fopen(tempfilepath, "wb");
    if (!tempfile) goto done;
@@ -78,9 +83,11 @@ edi_file_text_replace(const char *path, const char *search, 
const char *replace)
 
    fclose(tempfile);
    ecore_file_mv(tempfilepath, path);
+   free(tempfilepath);
 done:
    eina_file_map_free(f, map);
    eina_file_close(f);
+   free(tempfiledir);
 }
 
 static void

-- 


Reply via email to