added QSE_FS_MKDIR_IGNORE_UMASK

This commit is contained in:
hyung-hwan 2018-01-18 10:27:46 +00:00
parent 3f3d41528a
commit ffa5514b43
2 changed files with 20 additions and 2 deletions

View File

@ -282,8 +282,13 @@ typedef enum qse_fs_cpfile_flag_t qse_fs_cpfile_flag_t;
enum qse_fs_mkdir_flag_t enum qse_fs_mkdir_flag_t
{ {
QSE_FS_MKDIR_PARENT = (1 << 0), QSE_FS_MKDIR_PARENT = (1 << 0),
QSE_FS_MKDIR_IGNORE_UMASK = (1 << 1),
QSE_FS_MKDIRMBS_PARENT = QSE_FS_MKDIR_PARENT, QSE_FS_MKDIRMBS_PARENT = QSE_FS_MKDIR_PARENT,
QSE_FS_MKDIRWCS_PARENT = QSE_FS_MKDIR_PARENT QSE_FS_MKDIRWCS_PARENT = QSE_FS_MKDIR_PARENT,
QSE_FS_MKDIRMBS_IGNORE_UMASK = QSE_FS_MKDIR_IGNORE_UMASK,
QSE_FS_MKDIRWCS_IGNORE_UMASK = QSE_FS_MKDIR_IGNORE_UMASK
}; };
typedef enum qse_fs_mkdir_flag_t qse_fs_mkdir_flag_t; typedef enum qse_fs_mkdir_flag_t qse_fs_mkdir_flag_t;

View File

@ -28,7 +28,6 @@
int qse_fs_mkdirsys (qse_fs_t* fs, const qse_fs_char_t* fspath, qse_fs_mode_t mode) int qse_fs_mkdirsys (qse_fs_t* fs, const qse_fs_char_t* fspath, qse_fs_mode_t mode)
{ {
#if defined(_WIN32) #if defined(_WIN32)
if (CreateDirectory (fspath, QSE_NULL) == FALSE) if (CreateDirectory (fspath, QSE_NULL) == FALSE)
@ -139,6 +138,7 @@ done:
int qse_fs_mkdirmbs (qse_fs_t* fs, const qse_mchar_t* path, qse_fs_mode_t mode, int flags) int qse_fs_mkdirmbs (qse_fs_t* fs, const qse_mchar_t* path, qse_fs_mode_t mode, int flags)
{ {
qse_fs_char_t* fspath; qse_fs_char_t* fspath;
qse_fs_mode_t oldmask;
int ret; int ret;
if (*path == QSE_MT('\0')) if (*path == QSE_MT('\0'))
@ -154,14 +154,20 @@ int qse_fs_mkdirmbs (qse_fs_t* fs, const qse_mchar_t* path, qse_fs_mode_t mode,
fspath = qse_fs_dupfspathformbs (fs, path); fspath = qse_fs_dupfspathformbs (fs, path);
if (!fspath) return -1; if (!fspath) return -1;
/* [NOTE] the umask value is global. so changing it here affects other threads */
if (flags & QSE_FS_MKDIRMBS_IGNORE_UMASK) oldmask = QSE_UMASK(0);
ret = make_directory_chain (fs, fspath, mode); ret = make_directory_chain (fs, fspath, mode);
if (flags & QSE_FS_MKDIRWCS_IGNORE_UMASK) QSE_UMASK(oldmask);
} }
else else
{ {
fspath = (qse_fs_char_t*)qse_fs_makefspathformbs (fs, path); fspath = (qse_fs_char_t*)qse_fs_makefspathformbs (fs, path);
if (!fspath) return -1; if (!fspath) return -1;
/* [NOTE] the umask value is global. so changing it here affects other threads */
if (flags & QSE_FS_MKDIRMBS_IGNORE_UMASK) oldmask = QSE_UMASK(0);
ret = qse_fs_mkdirsys (fs, fspath, mode); ret = qse_fs_mkdirsys (fs, fspath, mode);
if (flags & QSE_FS_MKDIRWCS_IGNORE_UMASK) QSE_UMASK(oldmask);
} }
qse_fs_freefspathformbs (fs, path, fspath); qse_fs_freefspathformbs (fs, path, fspath);
@ -172,6 +178,7 @@ int qse_fs_mkdirmbs (qse_fs_t* fs, const qse_mchar_t* path, qse_fs_mode_t mode,
int qse_fs_mkdirwcs (qse_fs_t* fs, const qse_wchar_t* path, qse_fs_mode_t mode, int flags) int qse_fs_mkdirwcs (qse_fs_t* fs, const qse_wchar_t* path, qse_fs_mode_t mode, int flags)
{ {
qse_fs_char_t* fspath; qse_fs_char_t* fspath;
qse_fs_mode_t oldmask;
int ret; int ret;
if (*path == QSE_WT('\0')) if (*path == QSE_WT('\0'))
@ -187,14 +194,20 @@ int qse_fs_mkdirwcs (qse_fs_t* fs, const qse_wchar_t* path, qse_fs_mode_t mode,
fspath = qse_fs_dupfspathforwcs (fs, path); fspath = qse_fs_dupfspathforwcs (fs, path);
if (!fspath) return -1; if (!fspath) return -1;
/* [NOTE] the umask value is global. so changing it here affects other threads */
if (flags & QSE_FS_MKDIRWCS_IGNORE_UMASK) oldmask = QSE_UMASK(0);
ret = make_directory_chain (fs, fspath, mode); ret = make_directory_chain (fs, fspath, mode);
if (flags & QSE_FS_MKDIRWCS_IGNORE_UMASK) QSE_UMASK(oldmask);
} }
else else
{ {
fspath = (qse_fs_char_t*)qse_fs_makefspathforwcs (fs, path); fspath = (qse_fs_char_t*)qse_fs_makefspathforwcs (fs, path);
if (!fspath) return -1; if (!fspath) return -1;
/* [NOTE] the umask value is global. so changing it here affects other threads */
if (flags & QSE_FS_MKDIRWCS_IGNORE_UMASK) oldmask = QSE_UMASK(0);
ret = qse_fs_mkdirsys (fs, fspath, mode); ret = qse_fs_mkdirsys (fs, fspath, mode);
if (flags & QSE_FS_MKDIRWCS_IGNORE_UMASK) QSE_UMASK(oldmask);
} }
qse_fs_freefspathforwcs (fs, path, fspath); qse_fs_freefspathforwcs (fs, path, fspath);