based on Raphael's idea of tmpdir env vars and such - but different.
authorraster <raster@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Thu, 24 May 2012 05:07:22 +0000 (05:07 +0000)
committerraster <raster@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Thu, 24 May 2012 05:07:22 +0000 (05:07 +0000)
still disables unlink on non-linux.

git-svn-id: http://svn.enlightenment.org/svn/e/trunk/evas@71386 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/lib/canvas/evas_object_image.c

index 571570b..aa3c8e8 100644 (file)
@@ -221,7 +221,7 @@ _create_tmpf(Evas_Object *obj, void *data, int size, char *format __UNUSED__)
 {
 #ifdef HAVE_SYS_MMAN_H
    Evas_Object_Image *o;
-   char buf[4096];
+   char buf[PATH_MAX];
    void *dst;
    int fd = -1;
    
@@ -233,18 +233,31 @@ _create_tmpf(Evas_Object *obj, void *data, int size, char *format __UNUSED__)
 #endif   
    if (fd < 0)
      {
-        snprintf(buf, sizeof(buf), "/tmp/.evas-tmpf-%i-%p-%i-XXXXXX", 
-                 (int)getpid(), data, (int)size);
+        const char *tmpdir = getenv("TMPDIR");
+        
+        if (!tmpdir)
+          {
+             tmpdir = getenv("TMP");
+             if (!tmpdir)
+               {
+                  tmpdir = getenv("TEMP");
+                  if (!tmpdir) tmpdir = "/tmp";
+               }
+          }
+        snprintf(buf, sizeof(buf), "%s/.evas-tmpf-%i-%p-%i-XXXXXX", 
+                 tmpdir, (int)getpid(), data, (int)size);
         fd = mkstemp(buf);
+        if (fd < 0) return;
      }
-   if (fd < 0) return;
    if (ftruncate(fd, size) < 0)
      {
         unlink(buf);
         close(fd);
         return;
      }
+#ifdef __linux__
    unlink(buf);
+#endif
    
    eina_mmap_safety_enabled_set(EINA_TRUE);