28 #ifndef YCL_INC_FileSystem_h_
29 #define YCL_INC_FileSystem_h_ 1
32 #include YFM_YCLib_YCommon
38 #if YCL_DS || YCL_MinGW32 || YCL_Android
52 #define YCL_FS_StringIsCurrent(_s, _p) \
53 (ystdex::string_length(_s) == 1 && _s[0] == YPP_Concat(_p, '.'))
59 #define YCL_FS_StringIsParent(_s, _p) \
60 (ystdex::string_length(_s) == 2 \
61 && _s[0] == YPP_Concat(_p, '.') && _s[1] == YPP_Concat(_p, '.'))
75 #ifdef YCL_API_FILESYSTEM_POSIX
80 # define YCL_PATH_DELIMITER '/'
85 # define YCL_PATH_SEPARATOR "/"
89 # define YCL_PATH_ROOT YCL_PATH_SEPARATOR
95 using NativePathCharType = char;
97 # define YCL_FS_CharIsDelimiter(_c, _p) \
98 (_c == YPP_Join(_p, YCL_PATH_DELIMITER))
99 # define YCL_FS_StringIsRoot(_s, _p) (platform_ex::FS_IsRoot(&_s[0]))
111 # define YCL_PATH_DELIMITER '\\'
117 # define YCL_PATH_SEPARATOR "\\"
123 # define YCL_PATH_ROOT YCL_PATH_SEPARATOR
130 using NativePathCharType = char;
132 # define YCL_FS_CharIsDelimiter(_c, _p) \
133 (_c == YPP_Concat(_p, '/') || _c == YPP_Concat(_p, '\\'))
134 # define YCL_FS_StringIsRoot(_s, _p) \
135 (ystdex::string_length(_s) == 3 \
136 && _s[1] == ':' && YCL_FS_CharIsDelimiter(_s[2], _p))
144 # error "Unsupported platform found."
149 static_assert(std::is_integral<decltype(YCL_PATH_DELIMITER)>::value,
150 "Illegal type of delimiter found.");
152 YCL_PATH_SEPARATOR)>>::value,
"Non-array type of separator found.");
156 "Wrong length of separator found.");
157 static_assert(YCL_PATH_SEPARATOR[0] == YCL_PATH_DELIMITER,
158 "Mismatched path delimiter and separator found.");
160 "Non-null-terminator as end of separator.");
202 uopen(
const char16_t* filename,
int oflag,
int pmode)
ynothrow;
244 template<class _tString>
270 uchdir(const
char*) ynothrow;
278 umkdir(const
char*) ynothrow;
285 urmdir(const
char*) ynothrow;
310 truncate(std::FILE*, std::
size_t) ynothrow;
366 Communicator = 0x2000,
479 : DirectorySession(path)
490 PDefHOp(const
HDirectory&, *, ) const ynothrow
507 explicit
DefCvt(const ynothrow,
bool, p_dirent)
510 DefCvt(const, std::
string, GetName())
519 GetName() const ynothrow;
528 GetNodeCategory() const ynothrow;
531 using DirectorySession::Rewind;
558 namespace platform_ex
char16_t * u16getcwd_n(char16_t *buf, std::size_t size) ynothrow
DirectorySession(DirectorySession &&h)
YF_API bool IsAbsolute(const char *)
判断指定路径字符串是否表示一个绝对路径。
YF_API bool truncate(std::FILE *, std::size_t) ynothrow
截断文件至指定长度。
YF_API std::size_t GetRootNameLength(const char *)
取指定路径的文件系统根节点名称的长度。
typename remove_reference< _type >::type remove_reference_t
size_t arrlen(_type(&)[_vN])
计算指定数组类型对象的长度。
YF_API bool ufexists(const char *) ynothrow
判断指定 UTF-8 文件名的文件是否存在。
HDirectory(const char *path) ynothrow
构造:使用目录路径。
typename underlying_type< _type >::type underlying_type_t
yconstfn Integer &Trait::AMask Trait::XYZBitsN yconstfn DefGetter(const ynothrow, typename Trait::BType, B, Integer &Trait::XMask) yconstfn DefGetter(const ynothrow
yconstfn DefCvt(const ynothrow, typename Trait::IntegerType, Integer) yconstfn DefGetter(const ynothrow
std::size_t size ynothrow
YF_API bool uchdir(const char *) ynothrow
切换当前工作路径至指定的 UTF-8 字符串。
YF_API bool urmdir(const char *) ynothrow
按 UTF-8 路径删除一个空目录。
GSStringTemplate< char >::basic_string string
YF_API std::FILE * ufopen(const char *filename, const char *mode) ynothrow
以 UTF-8 文件名打开文件。
YF_API bool uunlink(const char *) ynothrow
按 UTF-8 路径删除一个非目录文件。
yconstexpr const KeyInput KeyIndex ynothrow ImplRet(char()) namespace KeyCodes
本机按键编码。
YF_API bool uremove(const char *) ynothrow
按 UTF-8 路径删除一个文件。
YF_API bool umkdir(const char *) ynothrow
按 UTF-8 路径以默认权限新建一个目录。
char16_t FS_IsRoot(const char16_t *)
#define yconstexpr
指定编译时常量表达式。
YF_API std::uint64_t GetFileSizeOf(int)
取文件的大小。
bool is_null(_tChar c)
使用 std::char_traits::eq 判断是否为空字符。
yconstexpr Encoding UTF_8(csUTF8)
FileOperationFailure(const std::string &msg="") ynothrow
YF_API int uopen(const char *filename, int oflag) ynothrow
以 UTF-8 文件名无缓冲打开文件。
PDefH(bool, ufexists, const _tString &str) ynothrow ImplRet(ufexists(str.c_str())) YF_API char16_t *u16getcwd_n(char16_t *buf
判断指定字符串为文件名的文件是否存在。