From 24417ff1a5885f9de89107e180aa273cab8567d0 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Andre Date: Tue, 19 Jan 2016 14:14:44 +0900 Subject: [PATCH] elua: Fix use of eina_file_mkstemp after previous patch The API (that didn't work in the first place) was used wrongly as it was assumed its behaviour was the same as mkstemp (duh!). It turns out eina's version doesn't replace the input string but returns a tmpstr instead. @fix --- src/lib/elua/cache.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/lib/elua/cache.c b/src/lib/elua/cache.c index 67268a4a2b..fe6825f0f9 100644 --- a/src/lib/elua/cache.c +++ b/src/lib/elua/cache.c @@ -59,19 +59,14 @@ writef(lua_State *L EINA_UNUSED, const void *p, size_t size, void *ud) static FILE * bc_tmp_open(const char *fname, char *buf, size_t buflen) { + Eina_Tmpstr *tmp_file; int fd; - /* FIXME: use ecore_file_file_get() ? */ - char *fs = strrchr(fname, '/'), *bs = strrchr(fname, '\\'); - if (!fs && !bs) - snprintf(buf, buflen, "./XXXXXX.cache"); - else - { - char *ss = (fs > bs) ? fs : bs; - snprintf(buf, buflen, "%.*sXXXXXX.cache", (int)(ss - fname + 1), fname); - } - fd = eina_file_mkstemp(buf, NULL); + snprintf(buf, buflen, "%s.XXXXXX.cache", fname); + fd = eina_file_mkstemp(buf, &tmp_file); if (fd < 0) return NULL; + eina_strlcpy(buf, tmp_file, buflen); + eina_tmpstr_del(tmp_file); return fdopen(fd, "wb"); } @@ -88,6 +83,7 @@ write_bc(lua_State *L, const char *fname) fclose(f); /* there really is nothing to handle here */ (void)!!remove(buf); + return; } else fclose(f); snprintf(buf2, sizeof(buf2), "%sc", fname);