qse/lib/si/fs-prv.h

219 lines
6.4 KiB
C
Raw Normal View History

/*
* $Id$
2011-10-14 15:51:20 +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>
#include <qse/cmn/mbwc.h>
#include <qse/cmn/mem.h>
#include <qse/cmn/str.h>
#include <qse/cmn/path.h>
#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
# define INCL_DOSFILEMGR
2012-02-21 09:23:51 +00:00
# include <os2.h>
typedef APIRET qse_fs_syserr_t;
#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;
#else
2016-04-29 03:55:42 +00:00
# include "../cmn/syscall.h"
typedef int qse_fs_syserr_t;
#endif
2011-10-14 15:51:20 +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)
# 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)
# 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
#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
#endif
#if defined(QSE_FS_CHAR_IS_MCHAR)
# define canon_fspath(path,canon,flags) qse_canonmbspath(path,canon,flags)
# define merge_fspath_dup(dir,file,mmgr) qse_mergembspathdup(dir,file,mmgr)
# define get_fspath_core(fspath) qse_mbspathcore(fspath)
# define get_fspath_base(fspath) qse_mbsbasename(fspath)
# 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)
# define merge_fspath_dup(dir,file,mmgr) qse_mergewcspathdup(dir,file,mmgr)
# define get_fspath_core(fspath) qse_wcspathcore(fspath)
# define get_fspath_base(fspath) qse_wcsbasename(fspath)
# define IS_FSPATHSEP(x) QSE_ISPATHWCSEP(x)
# define QSE_FS_T(x) QSE_WT(x)
#endif
#if defined(__cplusplus)
2011-10-14 15:51:20 +00:00
extern "C" {
#endif
qse_fs_errnum_t qse_fs_syserrtoerrnum (
qse_fs_t* fs,
qse_fs_syserr_t e
2011-10-14 15:51:20 +00:00
);
qse_fs_errnum_t qse_fs_direrrtoerrnum (
qse_fs_t* fs,
qse_dir_errnum_t e
);
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
);
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
);
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
int qse_fs_getattrsys (
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,
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,
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
);
2016-12-12 16:19:59 +00:00
int qse_fs_mkdirsys (
qse_fs_t* fs,
const qse_fs_char_t* fspath,
2019-03-14 01:23:44 +00:00
qse_fmode_t mode
);
2016-12-12 16:19:59 +00:00
int qse_fs_rmfilesys (
qse_fs_t* fs,
const qse_fs_char_t* fspath
);
2016-12-12 16:19:59 +00:00
int qse_fs_rmdirsys (
qse_fs_t* fs,
const qse_fs_char_t* fspath
2014-12-03 15:27:45 +00:00
);
int qse_fs_invokeactcb (
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
);
2019-03-14 01:23:44 +00:00
void qse_stat_to_attr (
const qse_stat_t* stat,
qse_fattr_t* attr
);
#if defined(__cplusplus)
2011-10-14 15:51:20 +00:00
}
#endif
2018-01-26 10:03:58 +00:00
#endif