Efreet, Elua : use eina_file_mkstemp instead of mkstemp

Reviewers: jpeg

Subscribers: cedric

Differential Revision: https://phab.enlightenment.org/D3411
This commit is contained in:
Vincent Torri 2015-12-08 14:24:59 +09:00 committed by Jean-Philippe Andre
parent a4a82ca003
commit 67f44a3cf8
3 changed files with 8 additions and 32 deletions

View File

@ -60,24 +60,16 @@ static FILE *
bc_tmp_open(const char *fname, char *buf, size_t buflen)
{
int fd;
#ifndef _WIN32
mode_t old_umask;
#endif
/* FIXME: use ecore_file_file_get() ? */
char *fs = strrchr(fname, '/'), *bs = strrchr(fname, '\\');
if (!fs && !bs)
snprintf(buf, buflen, "./XXXXXX");
snprintf(buf, buflen, "./XXXXXX.cache");
else
{
char *ss = (fs > bs) ? fs : bs;
snprintf(buf, buflen, "%.*sXXXXXX", (int)(ss - fname + 1), fname);
snprintf(buf, buflen, "%.*sXXXXXX.cache", (int)(ss - fname + 1), fname);
}
#ifndef _WIN32
old_umask = umask(S_IRWXG|S_IRWXO);
#endif
fd = mkstemp(buf);
#ifndef _WIN32
umask(old_umask);
#endif
fd = eina_file_mkstemp(buf, NULL);
if (fd < 0)
return NULL;
return fdopen(fd, "wb");

View File

@ -829,16 +829,8 @@ _surface_cap_cache_save()
sizeof(cap_dir_path));
/* use mkstemp for writing */
snprintf(tmp_file, sizeof(tmp_file), "%s.XXXXXX", cap_file_path);
#ifndef _WIN32
mode_t old_umask = umask(S_IRWXG|S_IRWXO);
#endif
tmpfd = mkstemp(tmp_file);
#ifndef _WIN32
umask(old_umask);
#endif
snprintf(tmp_file, sizeof(tmp_file), "%s.XXXXXX.cache", cap_file_path);
tmpfd = eina_file_mkstemp(tmp_file, NULL);
if (tmpfd < 0) goto error;
close(tmpfd);

View File

@ -264,16 +264,8 @@ _evas_gl_common_shader_binary_save(Evas_GL_Shared *shared)
sizeof(bin_dir_path));
/* use mkstemp for writing */
snprintf(tmp_file, sizeof(tmp_file), "%s.XXXXXX", bin_file_path);
#ifndef _WIN32
mode_t old_umask = umask(S_IRWXG|S_IRWXO);
#endif
tmpfd = mkstemp(tmp_file);
#ifndef _WIN32
umask(old_umask);
#endif
snprintf(tmp_file, sizeof(tmp_file), "%s.XXXXXX.cache", bin_file_path);
tmpfd = eina_file_mkstemp(tmp_file, NULL);
if (tmpfd < 0) return 0;
close(tmpfd);