based on Raphael's idea of tmpdir env vars and such - but different.

still disables unlink on non-linux.



SVN revision: 71386
This commit is contained in:
Carsten Haitzler 2012-05-24 05:07:22 +00:00
parent 63443c0c09
commit b249d37ce4
1 changed files with 17 additions and 4 deletions

View 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);