aboutsummaryrefslogtreecommitdiffstats
path: root/src/bin/efreet
diff options
context:
space:
mode:
authorVincent Torri <vincent dot torri at gmail dot com>2015-09-29 23:37:46 +0200
committerCedric BAIL <cedric@osg.samsung.com>2015-10-19 14:48:49 -0700
commitcb83f1477fe8c2eae823d963b988f5bdcbe8ff86 (patch)
tree1b89bcdf47318c219660cec8bf305246da33b3c2 /src/bin/efreet
parentecore_exe: terminate threads also in destructor (diff)
downloadefl-cb83f1477fe8c2eae823d963b988f5bdcbe8ff86.tar.gz
efreet: use eina_file_mkstemp() for portability and fix a bug on Windows
Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
Diffstat (limited to 'src/bin/efreet')
-rw-r--r--src/bin/efreet/efreetd_cache.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/bin/efreet/efreetd_cache.c b/src/bin/efreet/efreetd_cache.c
index a2ef783db8..e3aeb13f70 100644
--- a/src/bin/efreet/efreetd_cache.c
+++ b/src/bin/efreet/efreetd_cache.c
@@ -162,9 +162,9 @@ static void
subdir_cache_save(void)
{
char buf[PATH_MAX], buf2[PATH_MAX];
- int tmpfd;
- mode_t um;
Eet_File *ef;
+ Eina_Tmpstr *tmpstr = NULL;
+ int tmpfd;
// only if subdirs need saving... and we have subdirs.
if (!subdir_need_save) return;
@@ -172,16 +172,24 @@ subdir_cache_save(void)
if (!subdir_cache->dirs) return;
// save to tmp file first
- snprintf(buf2, sizeof(buf2), "%s/efreet/subdirs_%s.eet.XXXXXX", efreet_cache_home_get(), efreet_hostname_get());
- um = umask(0077);
- tmpfd = mkstemp(buf2);
- umask(um);
+ snprintf(buf2, sizeof(buf2), "%s/efreet/subdirs_%s.eet.XXXXXX.cache", efreet_cache_home_get(), efreet_hostname_get());
+ tmpfd = eina_file_mkstemp(buf2, &tmpstr);
if (tmpfd < 0) return;
- // write out eetf ile to tmp file
+ // write out eet file to tmp file
ef = eet_open(buf2, EET_FILE_MODE_WRITE);
eet_data_write(ef, subdir_edd, "subdirs", subdir_cache, EET_COMPRESSION_SUPERFAST);
eet_close(ef);
+ eina_tmpstr_del(tmpstr);
+
+ /*
+ * On Windows, buf2 has one remaining ref, hence it can not be renamed below.
+ * Stupid NTFS... So we close it first. "Magically", on Windows, this
+ * temporary file is not deleted...
+ */
+#ifdef _WIN32
+ close(tmpfd);
+#endif
// atomically rename subdirs file on top from tmp file
snprintf(buf, sizeof(buf), "%s/efreet/subdirs_%s.eet", efreet_cache_home_get(), efreet_hostname_get());