diff options
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); |