2011-11-20 16:24:11 +00:00
|
|
|
/*
|
|
|
|
* $Id$
|
2011-10-14 15:51:20 +00:00
|
|
|
*
|
2019-06-06 05:28:23 +00:00
|
|
|
Copyright (c) 2006-2019 Chung, Hyung-Hwan. All rights reserved.
|
2014-11-19 14:42:24 +00:00
|
|
|
|
|
|
|
Redistribution and use in source and binary forms, with or without
|
|
|
|
modification, are permitted provided that the following conditions
|
|
|
|
are met:
|
|
|
|
1. Redistributions of source code must retain the above copyright
|
|
|
|
notice, this list of conditions and the following disclaimer.
|
|
|
|
2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
notice, this list of conditions and the following disclaimer in the
|
|
|
|
documentation and/or other materials provided with the distribution.
|
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
|
|
|
|
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
2011-10-14 15:51:20 +00:00
|
|
|
*/
|
|
|
|
|
2018-01-26 10:03:58 +00:00
|
|
|
#ifndef _QSE_LIB_SI_FS_PRV_H_
|
|
|
|
#define _QSE_LIB_SI_FS_PRV_H_
|
|
|
|
|
2016-04-29 03:55:42 +00:00
|
|
|
#include <qse/si/fs.h>
|
|
|
|
#include <qse/si/glob.h>
|
|
|
|
#include <qse/si/dir.h>
|
2014-11-24 17:01:04 +00:00
|
|
|
#include <qse/cmn/mbwc.h>
|
|
|
|
#include <qse/cmn/mem.h>
|
|
|
|
#include <qse/cmn/str.h>
|
2014-11-27 15:58:51 +00:00
|
|
|
#include <qse/cmn/path.h>
|
2011-11-20 16:24:11 +00:00
|
|
|
|
|
|
|
#if defined(_WIN32)
|
|
|
|
# include <windows.h>
|
|
|
|
typedef DWORD qse_fs_syserr_t;
|
|
|
|
#elif defined(__OS2__)
|
2012-02-21 09:23:51 +00:00
|
|
|
# define INCL_DOSERRORS
|
2014-11-28 17:01:29 +00:00
|
|
|
# define INCL_DOSFILEMGR
|
2012-02-21 09:23:51 +00:00
|
|
|
# include <os2.h>
|
|
|
|
typedef APIRET qse_fs_syserr_t;
|
2011-11-20 16:24:11 +00:00
|
|
|
#elif defined(__DOS__)
|
2012-02-21 09:23:51 +00:00
|
|
|
# include <errno.h>
|
2012-02-21 12:54:42 +00:00
|
|
|
# include <io.h>
|
|
|
|
# include <stdio.h> /* for rename() */
|
2012-02-21 09:23:51 +00:00
|
|
|
typedef int qse_fs_syserr_t;
|
2011-11-20 16:24:11 +00:00
|
|
|
#else
|
2016-04-29 03:55:42 +00:00
|
|
|
# include "../cmn/syscall.h"
|
2011-11-20 16:24:11 +00:00
|
|
|
typedef int qse_fs_syserr_t;
|
|
|
|
#endif
|
2011-10-14 15:51:20 +00:00
|
|
|
|
2014-11-24 17:01:04 +00:00
|
|
|
#if defined(_WIN32) || defined(__OS2__) || defined(__DOS__)
|
2014-12-09 13:41:58 +00:00
|
|
|
# define DEFAULT_GLOB_FLAGS (QSE_GLOB_PERIOD | QSE_GLOB_SKIPSPCDIR | QSE_GLOB_NOESCAPE | QSE_GLOB_IGNORECASE)
|
2014-11-24 17:01:04 +00:00
|
|
|
# define DEFAULT_PATH_SEPARATOR QSE_T("\\")
|
|
|
|
#else
|
2014-12-09 13:41:58 +00:00
|
|
|
# define DEFAULT_GLOB_FLAGS (QSE_GLOB_PERIOD | QSE_GLOB_SKIPSPCDIR)
|
2014-11-24 17:01:04 +00:00
|
|
|
# define DEFAULT_PATH_SEPARATOR QSE_T("/")
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define IS_CURDIR(x) ((x)[0] == QSE_T('.') && (x)[1] == QSE_T('\0'))
|
|
|
|
#define IS_PREVDIR(x) ((x)[0] == QSE_T('.') && (x)[1] == QSE_T('.') && (x)[2] == QSE_T('\0'))
|
|
|
|
|
|
|
|
#if defined(QSE_CHAR_IS_MCHAR)
|
|
|
|
# define make_str_with_wcs(fs,wcs) qse_wcstombsdupwithcmgr(wcs,QSE_NULL,(fs)->mmgr,(fs)->cmgr)
|
|
|
|
# define make_str_with_mbs(fs,mbs) (mbs)
|
|
|
|
# define free_str_with_wcs(fs,wcs,str) QSE_MMGR_FREE((fs)->mmgr,str)
|
|
|
|
# define free_str_with_mbs(fs,mbs,str)
|
2016-12-12 16:19:59 +00:00
|
|
|
# if defined(QSE_FS_CHAR_IS_MCHAR)
|
|
|
|
# define make_str_with_fspath(fs,fspath) (fspath)
|
|
|
|
# define free_str_with_fspath(fs,mbs,str)
|
|
|
|
# else
|
|
|
|
# define make_str_with_fspath(fs,wcs) qse_wcstombsdupwithcmgr(wcs,QSE_NULL,(fs)->mmgr,(fs)->cmgr)
|
|
|
|
# define free_str_with_fspath(fs,wcs,str) QSE_MMGR_FREE((fs)->mmgr,str)
|
|
|
|
# endif
|
2014-11-24 17:01:04 +00:00
|
|
|
#else
|
|
|
|
# define make_str_with_wcs(fs,wcs) (wcs)
|
|
|
|
# define make_str_with_mbs(fs,mbs) qse_mbstowcsdupwithcmgr(mbs,QSE_NULL,(fs)->mmgr,(fs)->cmgr)
|
|
|
|
# define free_str_with_wcs(fs,wcs,str)
|
|
|
|
# define free_str_with_mbs(fs,mbs,str) QSE_MMGR_FREE((fs)->mmgr,str)
|
2016-12-12 16:19:59 +00:00
|
|
|
# if defined(QSE_FS_CHAR_IS_MCHAR)
|
|
|
|
# define make_str_with_fspath(fs,mbs) qse_mbstowcsdupwithcmgr(mbs,QSE_NULL,(fs)->mmgr,(fs)->cmgr)
|
|
|
|
# define free_str_with_fspath(fs,mbs,str) QSE_MMGR_FREE((fs)->mmgr,str)
|
|
|
|
# else
|
|
|
|
# define make_str_with_fspath(fs,fspath) (fspath)
|
|
|
|
# define free_str_with_fspath(fs,mbs,str)
|
|
|
|
# endif
|
2014-11-24 17:01:04 +00:00
|
|
|
#endif
|
|
|
|
|
2014-11-27 15:58:51 +00:00
|
|
|
#if defined(QSE_FS_CHAR_IS_MCHAR)
|
|
|
|
# define canon_fspath(path,canon,flags) qse_canonmbspath(path,canon,flags)
|
2014-12-08 15:07:55 +00:00
|
|
|
# define merge_fspath_dup(dir,file,mmgr) qse_mergembspathdup(dir,file,mmgr)
|
|
|
|
# define get_fspath_core(fspath) qse_mbspathcore(fspath)
|
2019-09-10 08:53:59 +00:00
|
|
|
# define get_fspath_base(fspath) qse_mbsbasename(fspath)
|
2014-11-27 15:58:51 +00:00
|
|
|
# define IS_FSPATHSEP(x) QSE_ISPATHMBSEP(x)
|
|
|
|
# define QSE_FS_T(x) QSE_MT(x)
|
|
|
|
#else
|
|
|
|
# define canon_fspath(fspath,canon,flags) qse_canonwcspath(fspath,canon,flags)
|
2014-12-08 15:07:55 +00:00
|
|
|
# define merge_fspath_dup(dir,file,mmgr) qse_mergewcspathdup(dir,file,mmgr)
|
|
|
|
# define get_fspath_core(fspath) qse_wcspathcore(fspath)
|
2019-09-10 08:53:59 +00:00
|
|
|
# define get_fspath_base(fspath) qse_wcsbasename(fspath)
|
2014-11-27 15:58:51 +00:00
|
|
|
# define IS_FSPATHSEP(x) QSE_ISPATHWCSEP(x)
|
|
|
|
# define QSE_FS_T(x) QSE_WT(x)
|
|
|
|
#endif
|
|
|
|
|
2014-11-14 02:44:20 +00:00
|
|
|
#if defined(__cplusplus)
|
2011-10-14 15:51:20 +00:00
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2011-11-20 16:24:11 +00:00
|
|
|
qse_fs_errnum_t qse_fs_syserrtoerrnum (
|
|
|
|
qse_fs_t* fs,
|
|
|
|
qse_fs_syserr_t e
|
2011-10-14 15:51:20 +00:00
|
|
|
);
|
|
|
|
|
2014-11-25 03:25:46 +00:00
|
|
|
qse_fs_errnum_t qse_fs_direrrtoerrnum (
|
|
|
|
qse_fs_t* fs,
|
|
|
|
qse_dir_errnum_t e
|
|
|
|
);
|
|
|
|
|
2014-11-24 17:01:04 +00:00
|
|
|
qse_fs_char_t* qse_fs_makefspathformbs (
|
|
|
|
qse_fs_t* fs,
|
|
|
|
const qse_mchar_t* path
|
|
|
|
);
|
|
|
|
|
|
|
|
qse_fs_char_t* qse_fs_makefspathforwcs (
|
|
|
|
qse_fs_t* fs,
|
|
|
|
const qse_wchar_t* path
|
|
|
|
);
|
|
|
|
|
2014-11-27 15:58:51 +00:00
|
|
|
qse_fs_char_t* qse_fs_dupfspathformbs (
|
|
|
|
qse_fs_t* fs,
|
|
|
|
const qse_mchar_t* path
|
|
|
|
);
|
|
|
|
|
|
|
|
qse_fs_char_t* qse_fs_dupfspathforwcs (
|
|
|
|
qse_fs_t* fs,
|
|
|
|
const qse_wchar_t* path
|
|
|
|
);
|
|
|
|
|
2014-11-24 17:01:04 +00:00
|
|
|
void qse_fs_freefspathformbs (
|
|
|
|
qse_fs_t* fs,
|
|
|
|
const qse_mchar_t* path,
|
|
|
|
qse_fs_char_t* fspath
|
|
|
|
);
|
|
|
|
|
|
|
|
void qse_fs_freefspathforwcs (
|
|
|
|
qse_fs_t* fs,
|
|
|
|
const qse_wchar_t* path,
|
|
|
|
qse_fs_char_t* fspath
|
|
|
|
);
|
|
|
|
|
|
|
|
#if defined(QSE_CHAR_IS_MCHAR)
|
|
|
|
# define qse_fs_makefspath(fs,path) qse_fs_makefspathformbs(fs,path)
|
|
|
|
# define qse_fs_freefspath(fs,path,fspath) qse_fs_freefspathformbs(fs,path,fspath);
|
|
|
|
#else
|
|
|
|
# define qse_fs_makefspath(fs,path) qse_fs_makefspathforwcs(fs,path)
|
|
|
|
# define qse_fs_freefspath(fs,path,fspath) qse_fs_freefspathforwcs(fs,path,fspath);
|
|
|
|
#endif
|
|
|
|
|
2016-12-10 18:08:02 +00:00
|
|
|
int qse_fs_getattrsys (
|
2014-12-11 16:03:58 +00:00
|
|
|
qse_fs_t* fs,
|
2014-12-03 15:27:45 +00:00
|
|
|
const qse_fs_char_t* fspath,
|
2019-03-14 01:23:44 +00:00
|
|
|
qse_fattr_t* attr,
|
2016-12-10 18:08:02 +00:00
|
|
|
int flags
|
|
|
|
);
|
|
|
|
|
|
|
|
int qse_fs_setattrsys (
|
|
|
|
qse_fs_t* fs,
|
|
|
|
qse_fs_char_t* path,
|
2019-03-14 01:23:44 +00:00
|
|
|
const qse_fattr_t* attr,
|
2016-12-10 18:08:02 +00:00
|
|
|
int flags /** bitwise-ORed #qse_fs_setattr_flag_t enumerators */
|
2014-12-17 15:29:05 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
int qse_fs_syscpfile (
|
|
|
|
qse_fs_t* fs,
|
|
|
|
const qse_fs_char_t* srcpath,
|
|
|
|
const qse_fs_char_t* dstpath
|
2014-12-11 16:03:58 +00:00
|
|
|
);
|
|
|
|
|
2016-12-12 16:19:59 +00:00
|
|
|
int qse_fs_mkdirsys (
|
2014-12-11 16:03:58 +00:00
|
|
|
qse_fs_t* fs,
|
2018-01-17 07:45:31 +00:00
|
|
|
const qse_fs_char_t* fspath,
|
2019-03-14 01:23:44 +00:00
|
|
|
qse_fmode_t mode
|
2014-12-11 16:03:58 +00:00
|
|
|
);
|
|
|
|
|
2016-12-12 16:19:59 +00:00
|
|
|
int qse_fs_rmfilesys (
|
2014-12-11 16:03:58 +00:00
|
|
|
qse_fs_t* fs,
|
|
|
|
const qse_fs_char_t* fspath
|
|
|
|
);
|
|
|
|
|
2016-12-12 16:19:59 +00:00
|
|
|
int qse_fs_rmdirsys (
|
2014-12-11 16:03:58 +00:00
|
|
|
qse_fs_t* fs,
|
|
|
|
const qse_fs_char_t* fspath
|
2014-12-03 15:27:45 +00:00
|
|
|
);
|
|
|
|
|
2016-12-18 17:12:21 +00:00
|
|
|
|
2017-01-25 06:30:43 +00:00
|
|
|
int qse_fs_invokeactcb (
|
2016-12-18 17:12:21 +00:00
|
|
|
qse_fs_t* fs,
|
|
|
|
qse_fs_action_t action,
|
|
|
|
qse_fs_char_t* src_fspath,
|
|
|
|
qse_fs_char_t* dst_fspath,
|
2018-01-26 10:03:58 +00:00
|
|
|
qse_uintmax_t bytes_total,
|
|
|
|
qse_uintmax_t bytes_done
|
2016-12-18 17:12:21 +00:00
|
|
|
);
|
|
|
|
|
2019-03-14 01:23:44 +00:00
|
|
|
void qse_stat_to_attr (
|
|
|
|
const qse_stat_t* stat,
|
|
|
|
qse_fattr_t* attr
|
|
|
|
);
|
|
|
|
|
2014-11-14 02:44:20 +00:00
|
|
|
#if defined(__cplusplus)
|
2011-10-14 15:51:20 +00:00
|
|
|
}
|
|
|
|
#endif
|
2018-01-26 10:03:58 +00:00
|
|
|
|
|
|
|
#endif
|