added the qse_fs_mode_t type and the mode parameter to qse_mkdir() and related functions

This commit is contained in:
2018-01-17 07:45:31 +00:00
parent db55393050
commit d991f9c27b
8 changed files with 151 additions and 22 deletions

View File

@ -515,7 +515,7 @@ start_over:
goto oops;
}
if (qse_fs_mkdirsys (fs, cpfile->dst_fspath) <= -1)
if (qse_fs_mkdirsys(fs, cpfile->dst_fspath, 0777) <= -1) /* TODO: copy mode? */
{
/* it's ok if the destination directory already exists */
if (fs->errnum != QSE_FS_EEXIST) goto oops;
@ -700,7 +700,7 @@ int qse_fs_cpfilembs (qse_fs_t* fs, const qse_mchar_t* srcpath, const qse_mchar_
if (flags & QSE_FS_CPFILE_GLOB)
{
fs->errnum = QSE_FS_ENOERR;
if (qse_globmbs (srcpath, copy_file_for_glob, &ctx, DEFAULT_GLOB_FLAGS, fs->mmgr, fs->cmgr) <= -1)
if (qse_globmbs(srcpath, copy_file_for_glob, &ctx, DEFAULT_GLOB_FLAGS, fs->mmgr, fs->cmgr) <= -1)
{
if (fs->errnum == QSE_FS_ENOERR) fs->errnum = QSE_FS_EGLOB;
ret = -1;
@ -738,7 +738,7 @@ int qse_fs_cpfilewcs (qse_fs_t* fs, const qse_wchar_t* srcpath, const qse_wchar_
if (flags & QSE_FS_CPFILE_GLOB)
{
fs->errnum = QSE_FS_ENOERR;
if (qse_globwcs (srcpath, copy_file_for_glob, &ctx, DEFAULT_GLOB_FLAGS, fs->mmgr, fs->cmgr) <= -1)
if (qse_globwcs(srcpath, copy_file_for_glob, &ctx, DEFAULT_GLOB_FLAGS, fs->mmgr, fs->cmgr) <= -1)
{
if (fs->errnum == QSE_FS_ENOERR) fs->errnum = QSE_FS_EGLOB;
ret = -1;

View File

@ -26,7 +26,7 @@
#include "fs-prv.h"
int qse_fs_mkdirsys (qse_fs_t* fs, const qse_fs_char_t* fspath)
int qse_fs_mkdirsys (qse_fs_t* fs, const qse_fs_char_t* fspath, qse_fs_mode_t mode)
{
#if defined(_WIN32)
@ -78,7 +78,7 @@ int qse_fs_mkdirsys (qse_fs_t* fs, const qse_fs_char_t* fspath)
#else
if (QSE_MKDIR (fspath, 0777) <= -1) /* TODO: proper mode?? */
if (QSE_MKDIR (fspath, mode) <= -1) /* TODO: proper mode?? */
{
fs->errnum = qse_fs_syserrtoerrnum (fs, errno);
return -1;
@ -91,7 +91,7 @@ int qse_fs_mkdirsys (qse_fs_t* fs, const qse_fs_char_t* fspath)
/* --------------------------------------------------------------------- */
static int make_directory_chain (qse_fs_t* fs, qse_fs_char_t* fspath)
static int make_directory_chain (qse_fs_t* fs, qse_fs_char_t* fspath, qse_fs_mode_t mode)
{
qse_fs_char_t* core, * p, c;
int ret = 0;
@ -120,7 +120,7 @@ static int make_directory_chain (qse_fs_t* fs, qse_fs_char_t* fspath)
c = *(p + 1);
*(p + 1) = QSE_FS_T('\0');
#endif
ret = qse_fs_mkdirsys (fs, fspath);
ret = qse_fs_mkdirsys (fs, fspath, mode);
if (ret <= -1 && fs->errnum != QSE_FS_EEXIST) goto done; /* abort */
#if defined(_WIN32) || defined(__DOS__) || defined(__OS2__)
*p = c;
@ -130,13 +130,13 @@ static int make_directory_chain (qse_fs_t* fs, qse_fs_char_t* fspath)
}
}
if (!IS_FSPATHSEP(*(p - 1))) ret = qse_fs_mkdirsys (fs, fspath);
if (!IS_FSPATHSEP(*(p - 1))) ret = qse_fs_mkdirsys (fs, fspath, mode);
done:
return ret;
}
int qse_fs_mkdirmbs (qse_fs_t* fs, const qse_mchar_t* path, 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;
int ret;
@ -154,14 +154,14 @@ int qse_fs_mkdirmbs (qse_fs_t* fs, const qse_mchar_t* path, int flags)
fspath = qse_fs_dupfspathformbs (fs, path);
if (!fspath) return -1;
ret = make_directory_chain (fs, fspath);
ret = make_directory_chain (fs, fspath, mode);
}
else
{
fspath = (qse_fs_char_t*)qse_fs_makefspathformbs (fs, path);
if (!fspath) return -1;
ret = qse_fs_mkdirsys (fs, fspath);
ret = qse_fs_mkdirsys (fs, fspath, mode);
}
qse_fs_freefspathformbs (fs, path, fspath);
@ -169,7 +169,7 @@ int qse_fs_mkdirmbs (qse_fs_t* fs, const qse_mchar_t* path, int flags)
return ret;
}
int qse_fs_mkdirwcs (qse_fs_t* fs, const qse_wchar_t* path, 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;
int ret;
@ -187,14 +187,14 @@ int qse_fs_mkdirwcs (qse_fs_t* fs, const qse_wchar_t* path, int flags)
fspath = qse_fs_dupfspathforwcs (fs, path);
if (!fspath) return -1;
ret = make_directory_chain (fs, fspath);
ret = make_directory_chain (fs, fspath, mode);
}
else
{
fspath = (qse_fs_char_t*)qse_fs_makefspathforwcs (fs, path);
if (!fspath) return -1;
ret = qse_fs_mkdirsys (fs, fspath);
ret = qse_fs_mkdirsys (fs, fspath, mode);
}
qse_fs_freefspathforwcs (fs, path, fspath);

View File

@ -179,7 +179,8 @@ int qse_fs_syscpfile (
int qse_fs_mkdirsys (
qse_fs_t* fs,
const qse_fs_char_t* fspath
const qse_fs_char_t* fspath,
qse_fs_mode_t mode
);
int qse_fs_rmfilesys (

View File

@ -103,8 +103,7 @@ static qse_sio_errnum_t tio_errnum_to_sio_errnum (qse_tio_t* tio)
}
}
qse_sio_t* qse_sio_open (
qse_mmgr_t* mmgr, qse_size_t xtnsize, const qse_char_t* file, int flags)
qse_sio_t* qse_sio_open (qse_mmgr_t* mmgr, qse_size_t xtnsize, const qse_char_t* file, int flags)
{
qse_sio_t* sio;
@ -161,8 +160,7 @@ void qse_sio_close (qse_sio_t* sio)
QSE_MMGR_FREE (sio->mmgr, sio);
}
int qse_sio_init (
qse_sio_t* sio, qse_mmgr_t* mmgr, const qse_char_t* path, int flags)
int qse_sio_init (qse_sio_t* sio, qse_mmgr_t* mmgr, const qse_char_t* path, int flags)
{
int mode;
int topt = 0;