diff options
author | Jean-Philippe Andre <jp.andre@samsung.com> | 2016-01-19 14:14:44 +0900 |
---|---|---|
committer | Jean-Philippe Andre <jp.andre@samsung.com> | 2016-01-19 18:18:29 +0900 |
commit | 24417ff1a5885f9de89107e180aa273cab8567d0 (patch) | |
tree | a7a8a222141ee5496598748fda48157c9cdba744 /src/lib/elua/cache.c | |
parent | c8baf41149e59dde626ce64b56c7961efb6b8ab0 (diff) |
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
Diffstat (limited to 'src/lib/elua/cache.c')
-rw-r--r-- | src/lib/elua/cache.c | 16 |
1 files 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) | |||
59 | static FILE * | 59 | static FILE * |
60 | bc_tmp_open(const char *fname, char *buf, size_t buflen) | 60 | bc_tmp_open(const char *fname, char *buf, size_t buflen) |
61 | { | 61 | { |
62 | Eina_Tmpstr *tmp_file; | ||
62 | int fd; | 63 | int fd; |
63 | /* FIXME: use ecore_file_file_get() ? */ | 64 | snprintf(buf, buflen, "%s.XXXXXX.cache", fname); |
64 | char *fs = strrchr(fname, '/'), *bs = strrchr(fname, '\\'); | 65 | fd = eina_file_mkstemp(buf, &tmp_file); |
65 | if (!fs && !bs) | ||
66 | snprintf(buf, buflen, "./XXXXXX.cache"); | ||
67 | else | ||
68 | { | ||
69 | char *ss = (fs > bs) ? fs : bs; | ||
70 | snprintf(buf, buflen, "%.*sXXXXXX.cache", (int)(ss - fname + 1), fname); | ||
71 | } | ||
72 | fd = eina_file_mkstemp(buf, NULL); | ||
73 | if (fd < 0) | 66 | if (fd < 0) |
74 | return NULL; | 67 | return NULL; |
68 | eina_strlcpy(buf, tmp_file, buflen); | ||
69 | eina_tmpstr_del(tmp_file); | ||
75 | return fdopen(fd, "wb"); | 70 | return fdopen(fd, "wb"); |
76 | } | 71 | } |
77 | 72 | ||
@@ -88,6 +83,7 @@ write_bc(lua_State *L, const char *fname) | |||
88 | fclose(f); | 83 | fclose(f); |
89 | /* there really is nothing to handle here */ | 84 | /* there really is nothing to handle here */ |
90 | (void)!!remove(buf); | 85 | (void)!!remove(buf); |
86 | return; | ||
91 | } | 87 | } |
92 | else fclose(f); | 88 | else fclose(f); |
93 | snprintf(buf2, sizeof(buf2), "%sc", fname); | 89 | snprintf(buf2, sizeof(buf2), "%sc", fname); |