forked from enlightenment/efl
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
This commit is contained in:
parent
c8baf41149
commit
24417ff1a5
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue