forked from enlightenment/efl
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:
parent
a4a82ca003
commit
67f44a3cf8
|
@ -60,24 +60,16 @@ static FILE *
|
||||||
bc_tmp_open(const char *fname, char *buf, size_t buflen)
|
bc_tmp_open(const char *fname, char *buf, size_t buflen)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
#ifndef _WIN32
|
/* FIXME: use ecore_file_file_get() ? */
|
||||||
mode_t old_umask;
|
|
||||||
#endif
|
|
||||||
char *fs = strrchr(fname, '/'), *bs = strrchr(fname, '\\');
|
char *fs = strrchr(fname, '/'), *bs = strrchr(fname, '\\');
|
||||||
if (!fs && !bs)
|
if (!fs && !bs)
|
||||||
snprintf(buf, buflen, "./XXXXXX");
|
snprintf(buf, buflen, "./XXXXXX.cache");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
char *ss = (fs > bs) ? fs : bs;
|
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
|
fd = eina_file_mkstemp(buf, NULL);
|
||||||
old_umask = umask(S_IRWXG|S_IRWXO);
|
|
||||||
#endif
|
|
||||||
fd = mkstemp(buf);
|
|
||||||
#ifndef _WIN32
|
|
||||||
umask(old_umask);
|
|
||||||
#endif
|
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
return fdopen(fd, "wb");
|
return fdopen(fd, "wb");
|
||||||
|
|
|
@ -829,16 +829,8 @@ _surface_cap_cache_save()
|
||||||
sizeof(cap_dir_path));
|
sizeof(cap_dir_path));
|
||||||
|
|
||||||
/* use mkstemp for writing */
|
/* use mkstemp for writing */
|
||||||
snprintf(tmp_file, sizeof(tmp_file), "%s.XXXXXX", cap_file_path);
|
snprintf(tmp_file, sizeof(tmp_file), "%s.XXXXXX.cache", cap_file_path);
|
||||||
|
tmpfd = eina_file_mkstemp(tmp_file, NULL);
|
||||||
#ifndef _WIN32
|
|
||||||
mode_t old_umask = umask(S_IRWXG|S_IRWXO);
|
|
||||||
#endif
|
|
||||||
tmpfd = mkstemp(tmp_file);
|
|
||||||
#ifndef _WIN32
|
|
||||||
umask(old_umask);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (tmpfd < 0) goto error;
|
if (tmpfd < 0) goto error;
|
||||||
close(tmpfd);
|
close(tmpfd);
|
||||||
|
|
||||||
|
|
|
@ -264,16 +264,8 @@ _evas_gl_common_shader_binary_save(Evas_GL_Shared *shared)
|
||||||
sizeof(bin_dir_path));
|
sizeof(bin_dir_path));
|
||||||
|
|
||||||
/* use mkstemp for writing */
|
/* use mkstemp for writing */
|
||||||
snprintf(tmp_file, sizeof(tmp_file), "%s.XXXXXX", bin_file_path);
|
snprintf(tmp_file, sizeof(tmp_file), "%s.XXXXXX.cache", bin_file_path);
|
||||||
|
tmpfd = eina_file_mkstemp(tmp_file, NULL);
|
||||||
#ifndef _WIN32
|
|
||||||
mode_t old_umask = umask(S_IRWXG|S_IRWXO);
|
|
||||||
#endif
|
|
||||||
tmpfd = mkstemp(tmp_file);
|
|
||||||
#ifndef _WIN32
|
|
||||||
umask(old_umask);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (tmpfd < 0) return 0;
|
if (tmpfd < 0) return 0;
|
||||||
close(tmpfd);
|
close(tmpfd);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue