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 *
|
static FILE *
|
||||||
bc_tmp_open(const char *fname, char *buf, size_t buflen)
|
bc_tmp_open(const char *fname, char *buf, size_t buflen)
|
||||||
{
|
{
|
||||||
|
Eina_Tmpstr *tmp_file;
|
||||||
int fd;
|
int fd;
|
||||||
/* FIXME: use ecore_file_file_get() ? */
|
snprintf(buf, buflen, "%s.XXXXXX.cache", fname);
|
||||||
char *fs = strrchr(fname, '/'), *bs = strrchr(fname, '\\');
|
fd = eina_file_mkstemp(buf, &tmp_file);
|
||||||
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);
|
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
eina_strlcpy(buf, tmp_file, buflen);
|
||||||
|
eina_tmpstr_del(tmp_file);
|
||||||
return fdopen(fd, "wb");
|
return fdopen(fd, "wb");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,6 +83,7 @@ write_bc(lua_State *L, const char *fname)
|
||||||
fclose(f);
|
fclose(f);
|
||||||
/* there really is nothing to handle here */
|
/* there really is nothing to handle here */
|
||||||
(void)!!remove(buf);
|
(void)!!remove(buf);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else fclose(f);
|
else fclose(f);
|
||||||
snprintf(buf2, sizeof(buf2), "%sc", fname);
|
snprintf(buf2, sizeof(buf2), "%sc", fname);
|
||||||
|
|
Loading…
Reference in New Issue