Vincent Torri <vincent.to...@gmail.com> writes:
> On Mon, May 21, 2012 at 10:28 AM, Joerg Sonnenberger
> <jo...@britannica.bec.de> wrote:
>> On Mon, May 21, 2012 at 12:15:10AM -0300, Raphael Kubo da Costa wrote:
>>> After talking about the previous version of the patch with raster on
>>> IRC, I'm sending a more conservative version that does not change the
>>> Linux behavior -- /dev/shm is expected to work on Linux, and the
>>> non-Linux case works at the expense of leaving some files in /tmp if a
>>> crash occurs before _cleanup_tmpf() is called.
>>
>> Can you not hard-code /tmp, but try to honor TMPDIR?
>
> TMPDIR does not exist on Windows. TMP and TEMP do
New attempt attached: we now check TMPDIR, TMP and TEMP (in this order)
before falling back to "/tmp".
Index: src/lib/canvas/evas_object_image.c
===================================================================
--- src/lib/canvas/evas_object_image.c (revision 71134)
+++ src/lib/canvas/evas_object_image.c (working copy)
@@ -203,8 +203,7 @@
o = (Evas_Object_Image *)(obj->object_data);
if (!o->tmpf) return;
-#ifdef __linux__
-#else
+#ifndef __linux__
unlink(o->tmpf);
#endif
if (o->tmpf_fd >= 0) close(o->tmpf_fd);
@@ -224,19 +223,22 @@
char buf[4096];
void *dst;
int fd = -1;
+ const char *tmpdir;
o = (Evas_Object_Image *)(obj->object_data);
+
#ifdef __linux__
snprintf(buf, sizeof(buf), "/dev/shm/.evas-tmpf-%i-%p-%i-XXXXXX",
(int)getpid(), data, (int)size);
+#else
+ 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);
+#endif
fd = mkstemp(buf);
-#endif
- if (fd < 0)
- {
- snprintf(buf, sizeof(buf), "/tmp/.evas-tmpf-%i-%p-%i-XXXXXX",
- (int)getpid(), data, (int)size);
- fd = mkstemp(buf);
- }
if (fd < 0) return;
if (ftruncate(fd, size) < 0)
{
@@ -244,7 +246,9 @@
close(fd);
return;
}
+#ifdef __linux__
unlink(buf);
+#endif
eina_mmap_safety_enabled_set(EINA_TRUE);
@@ -269,6 +273,7 @@
(void) data;
(void) size;
(void) format;
+ (void) tmpdir;
#endif
}
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel