YSTest: FileSystem.h 源文件

YSTest PreAlpha_b900_20201012 The YSLib Test Project

YSLib/Service/FileSystem.h
浏览该文件的文档.
1 /*
2 © 2010-2016, 2018-2020 FrankHB.
3
4 This file is part of the YSLib project, and may only be used,
5 modified, and distributed under the terms of the YSLib project
6 license, LICENSE.TXT. By continuing to use, modify, or distribute
7 this file you indicate that you have read the license and
8 understand and accept it fully.
9 */
10
28 #ifndef YSL_INC_Service_FileSystem_h_
29 #define YSL_INC_Service_FileSystem_h_ 1
30
31 #include "YModules.h"
32 #include YFM_YSLib_Service_File // for YSLib::CheckNonnegative, function,
33 // IO::Remove;
34 #include YFM_YSLib_Core_YString
35 #include <ystdex/algorithm.hpp> // for ystdex::split;
36 #include <ystdex/path.hpp> // for ystdex::path;
37
38 namespace YSLib
39 {
40
41 namespace IO
42 {
43
45 using NativePathView = basic_string_view<HDirectory::NativeChar>;
46
52 yconstexpr const size_t MaxPathLength(yimpl(1 << 10));
53
54
60 inline PDefH(bool, IsAbsolute, const string& path)
61 ImplRet(IsAbsolute(path.c_str()))
62 inline PDefH(bool, IsAbsolute, const String& path)
63 ImplRet(IsAbsolute(path.GetMBCS()))
65
71 template<typename _type>
72 inline bool
73 IsRelative(const _type& arg)
74 {
75 return !IsAbsolute(arg);
76 }
77
78
90 struct PathTraits : ystdex::path_traits<void>
91 {
92 using value_type = YSLib::String;
93
95 template<typename _tChar>
96 static yconstfn bool
97 IsDelimiter(_tChar c) ynothrow
98 {
99 return IO::IsSeparator(c);
100 }
101
103
104 template<class _tString>
105 static yconstfn bool
106 is_absolute(const _tString& str) ynothrow
107 {
108 return has_root_path(str) && (ystdex::string_empty(str)
109 || IO::IsSeparator(str[ystdex::string_length(str) - 1]));
110 }
111
112 template<class _tString>
113 static yconstfn bool
114 has_root_path(const _tString& str) ynothrow
115 {
116 return ystdex::string_length(str) == IO::FetchRootPathLength(str);
117 }
118
119 template<class _tString>
120 static yconstfn bool
121 has_root_name(const _tString& str) ynothrow
122 {
123 return !ystdex::string_empty(str) && IO::FetchRootNameLength(str) != 0;
124 }
126 };
127
128
134 template<class _tString>
135 inline ystdex::decay_t<_tString>
136 NormalizeDirectoryPathTail(_tString&& str, typename
137 ystdex::string_traits<_tString>::const_pointer tail = &ystdex::to_array<
138 typename ystdex::string_traits<_tString>::value_type>("/\\")[0])
139 {
140 using value_type = typename ystdex::string_traits<_tString>::value_type;
141
142 TrimTrailingSeperator(yforward(str), tail);
143 YAssert(str.empty() || !IsSeparator(str.back()), "Invalid path converted.");
144 str += FetchSeparator<value_type>();
145 return yforward(str);
146 }
147
148
161 template<class _tPath, typename _func,
162 class _tStringView = string_view_t<typename _tPath::value_type>,
163 class _tTraits = typename _tPath::traits_type>
164 _tPath
165 ParsePathWith(_tStringView sv, _func f, _tPath res = {})
166 {
167 using ystdex::cbegin;
168 using ystdex::cend;
169
170 YAssertNonnull(sv.data());
171
172 const auto l(IO::FetchRootPathLength(sv));
173
174 if(l != 0 && res.empty())
175 res.push_back(typename _tPath::value_type(sv.substr(0, l)));
176 // XXX: Conversion to 'ptrdiff_t' might be implementation-defined.
177 ystdex::split(cbegin(sv) + YSLib::CheckNonnegative<ptrdiff_t>(l), cend(sv),
178 [](decltype(*cbegin(sv)) c) ynothrow{
179 return _tTraits::IsDelimiter(c);
180 }, [&](decltype(cbegin(sv)) b, decltype(cend(sv)) e){
181 if(b != e)
182 f(res, b, e);
183 });
184 return res;
185 }
186
187 template<class _tPath,
188 class _tStringView = string_view_t<typename _tPath::value_type>,
189 class _tTraits = typename _tPath::traits_type>
190 _tPath
191 ParsePath(_tStringView sv, _tPath res = {})
192 {
193 using ystdex::cbegin;
194 using ystdex::cend;
195
196 return IO::ParsePathWith<_tPath>(sv,
197 [&](_tPath& pth, decltype(cbegin(sv)) b, decltype(cend(sv)) e){
198 pth.push_back(typename _tPath::value_type(b, e));
199 }, std::move(res));
200 }
202
203
205 using ypath = ystdex::path<vector<String>, PathTraits>;
206
207
215 class YF_API Path : private ypath, private ystdex::totally_ordered<Path>,
216 private ystdex::dividable<Path, String>, private ystdex::dividable<Path>
217 {
218 public:
219 using ypath::iterator;
220 using ypath::const_iterator;
222 using ypath::value_type;
224 using ypath::traits_type;
225
226 public:
230 DefDeCtor(Path)
232 explicit
233 Path(ypath pth) ynothrow
234 : ypath(std::move(pth))
235 {}
240 template<typename _type, yimpl(typename = ystdex::enable_if_t<
241 ystdex::or_<std::is_constructible<u16string_view, _type>,
242 std::is_constructible<String, _type>>::value>,
243 typename = ystdex::exclude_self_t<Path, _type>)>
244 explicit
245 Path(_type&& arg)
246 : ypath(ParsePath<ypath>(u16string_view(AsStringArg(yforward(arg)))))
247 {}
249 template<typename _type>
250 explicit
251 Path(_type&& arg, Text::Encoding enc)
252 : ypath(ParsePath<ypath>(u16string_view(String(yforward(arg), enc))))
253 {}
255 template<typename _tIn>
256 Path(_tIn first, _tIn last)
257 : ypath(first, last)
258 {}
260 template<typename _tElem>
261 Path(std::initializer_list<_tElem> il)
262 : ypath(il)
263 {}
267 DefDeCopyCtor(Path)
271 DefDeMoveCtor(Path)
272 DefDeDtor(Path)
273
274
278 DefDeCopyAssignment(Path)
283 DefDeMoveAssignment(Path)
284
285
286
287 PDefHOp(Path&, /=, const Path& pth)
288 ImplRet(GetBaseRef() /= pth, *this)
290 PDefHOp(Path&, /=, const ypath& pth)
291 ImplRet(GetBaseRef() /= pth, *this)
293 template<typename _type, yimpl(typename = ystdex::enable_if_t<
294 ystdex::or_<std::is_constructible<u16string_view, _type>,
295 std::is_constructible<String, _type>>::value>,
296 typename = ystdex::exclude_self_t<Path, _type>,
297 typename = ystdex::exclude_self_t<ypath, _type>)>
298 Path&
299 operator/=(_type&& arg)
300 {
301 // NOTE: Since effective insertion of path needs %value_type, the
302 // conversion to %String is always required here. No other string view
303 // type is needed to be handled specially.
304 return GetBaseRef() /= String(AsStringArg(yforward(arg))), *this;
305 }
307
308 YB_ATTR_nodiscard YB_PURE friend
309 PDefHOp(bool, ==, const Path& x, const Path& y)
310 ImplRet(x.GetBase() == y.GetBase())
311
312 YB_ATTR_nodiscard YB_PURE friend
313 PDefHOp(bool, <, const Path& x, const Path& y)
314 ImplRet(x.GetBase() < y.GetBase())
315
321 explicit
322 DefCvt(const, String, GetLeafString())
327 explicit
328 DefCvt(const, string, String(*this).GetMBCS())
329
331 DefGetter(const ynothrow, const ypath&, Base, *this)
333 DefGetter(ynothrow, ypath&, BaseRef, *this)
335
336 PDefH(String, GetLeafString,
338 char16_t delimiter = FetchSeparator<char16_t>()) const
339 ImplRet(ystdex::to_string(GetBase(), {delimiter}))
344 String
345 GetString(char16_t = FetchSeparator<char16_t>()) const;
347
348 private:
350
351 template<typename _tParam>
352 auto
353 AsStringArg(_tParam&& arg) -> yimpl(ystdex::enable_if_t)<
354 std::is_constructible<u16string_view, _tParam>::value, u16string_view>
355 {
356 return u16string_view(yforward(arg));
357 }
358 template<typename _tParam, yimpl(typename = ystdex::enable_if_t<
359 ystdex::and_<ystdex::not_<std::is_constructible<u16string_view,
360 _tParam>>, std::is_constructible<String, _tParam>>::value>)>
361 String
362 AsStringArg(_tParam&& arg)
363 {
364 return String(yforward(arg));
365 }
367
368 public:
373 PDefH(void, Normalize, )
374 ImplExpr(ystdex::normalize(*this))
375
383 String
384 Verify(char16_t = FetchSeparator<char16_t>()) const;
389 PDefH(string, VerifyAsMBCS,
390 char16_t delimiter = char16_t(FetchSeparator<char16_t>()),
391 Text::Encoding enc = Text::CS_Default) const
392 ImplRet(Verify(delimiter).GetMBCS(enc))
393
395
396 using ypath::back;
397
398 using ypath::begin;
399
400 using ypath::cbegin;
401
402 using ypath::clear;
403
404 using ypath::cend;
405
406 using ypath::empty;
407
408 using ypath::end;
409
410 using ypath::erase;
411
413 using ypath::filter_self;
414
415 using ypath::front;
416
418 using ypath::has_leaf;
419
421 using ypath::has_leaf_nonempty;
422
423 using ypath::insert;
424
425 using ypath::is_absolute;
426
427 using ypath::is_relative;
428
430 using ypath::max_size;
431
433 using ypath::merge_parents;
434
436 using ypath::pop_back;
437
439 using ypath::push_back;
440
442 using ypath::redirect;
443
445 using ypath::remove_leaf;
446
448 using ypath::size;
449
451
452 friend PDefH(void, swap, Path& x, ypath& y)
453 ImplExpr(y.swap(x));
454 friend PDefH(void, swap, ypath& x, Path& y)
455 ImplExpr(x.swap(y));
456 friend PDefH(void, swap, Path& x, Path& y)
457 ImplExpr(y.GetBaseRef().swap(x))
459
461 friend PDefH(String, to_string, const Path& pth)
462 ImplRet(to_string(pth.GetBase(), {FetchSeparator<char16_t>()}))
464 };
465
466
473 template<class _tString>
475 _tString
476 GetExtensionOf(const _tString& fname)
477 {
478 return ystdex::find_suffix(fname, typename _tString::value_type('.'));
479 }
481 inline PDefH(String, GetExtensionOf, const Path& pth)
482 ImplRet(pth.empty() ? String() : GetExtensionOf(pth.back()))
484
485
486
488
492 inline PDefH(bool, IsAbsolute, const Path& pth)
493 ImplRet(!pth.empty() && IsAbsolute(pth.GetString()))
494
505 YF_API Path
506 MakeNormalizedAbsolute(const Path&, size_t = MaxPathLength);
508
509
516 YF_API YB_NONNULL(1) bool
517 VerifyDirectory(const char*);
519 YF_API YB_NONNULL(1) bool
520 VerifyDirectory(const char16_t*);
521 inline PDefH(bool, VerifyDirectory, const string& path)
522 ImplRet(VerifyDirectory(path.c_str()))
524 inline PDefH(bool, VerifyDirectory, const u16string& path)
525 ImplRet(VerifyDirectory(path.c_str()))
526 inline PDefH(bool, VerifyDirectory, const String& path)
527 ImplRet(VerifyDirectory(path.c_str()))
528 inline PDefH(bool, VerifyDirectory, const Path& pth)
529 ImplRet(!pth.empty() && VerifyDirectory(pth.GetString()))
531
537 template<class _tString>
538 inline ystdex::decay_t<_tString>
539 VerifyDirectoryPathTail(_tString&& str)
540 {
541 if(!(str.empty() || VerifyDirectory(str)))
542 str.pop_back();
543 return yforward(str);
544 }
545
546
554 YF_API void
555 EnsureDirectory(const Path&);
556 inline PDefH(void, EnsureDirectory, const char* path)
557 ImplExpr(EnsureDirectory(Path(path)))
558 inline PDefH(void, EnsureDirectory, const string& path)
559 ImplExpr(EnsureDirectory(path.c_str()))
560 inline PDefH(void, EnsureDirectory, const String& path)
561 ImplExpr(EnsureDirectory(path.GetMBCS()))
563
564
580 template<class _tPath = Path,
581 class _tStringView = string_view_t<typename _tPath::value_type>,
582 class _tTraits = typename _tPath::traits_type>
583 _tPath
584 ResolvePathWithBase(_tStringView sv, _tPath base,
585 size_t n = FetchLimit(SystemOption::MaxSymlinkLoop))
586 {
587 using ystdex::cbegin;
588 using ystdex::cend;
589
590 if(IsAbsolute(sv.data()))
591 base.clear();
592 return IO::ParsePathWith<_tPath>(sv,
593 [&](_tPath& pth, decltype(cbegin(sv)) b, decltype(cend(sv)) e){
594 // NOTE: Since the underlying call would resolve the path of the link,
595 // there is no need to resolve it using %operator/= here.
596 pth.push_back(typename _tPath::value_type(b, e));
597
598 // XXX: This may be not efficient because underlying calls will resolve
599 // the path prefix repeatedly.
600 auto str(to_string(pth));
601
602 // FIXME: Blocked. TOCTTOU access.
603 if(IO::IterateLink(str, n))
604 pth.redirect(IO::ParsePath<_tPath>(std::move(str)));
605 }, std::move(base));
606 }
607
612 template<class _tPath = Path, class _tString = typename _tPath::value_type,
613 class _tTraits = typename _tPath::traits_type>
614 _tPath
615 ResolvePath(const _tString& sv,
616 size_t n = FetchLimit(SystemOption::MaxSymlinkLoop),
617 size_t init_len = MaxPathLength)
618 {
619 return IO::ResolvePathWithBase(sv, IsAbsolute(sv.data()) ? _tPath()
620 : IO::ParsePath<_tPath>(FetchCurrentWorkingDirectory<typename
621 _tString::value_type>(init_len)), n);
622 }
624
625
631 template<typename _func>
632 void
633 Traverse(HDirectory& dir, _func f)
634 {
635 for(NativePathView npv : dir)
636 {
637 YAssert(!npv.empty(), "Empty name found.");
638 // TODO: Allow user code to specify filtering on self node?
639 if(!PathTraits::is_self(npv))
640 f(dir.GetNodeCategory(), npv);
641 }
642 }
644
645
647 template<typename _func>
649 YB_NONNULL(1) inline void
650 Traverse(const char* path, _func f)
651 {
652 // NOTE: Separators at end of path is allowed by %HDirectory::HDirectory.
653 HDirectory dir(path);
654
655 IO::Traverse(dir, f);
656 }
658 template<typename _func>
659 inline void
660 Traverse(const string& path, _func f)
661 {
662 IO::Traverse(path.c_str(), f);
663 }
665 template<typename _func>
666 inline void
667 Traverse(const Path& pth, _func f)
668 {
669 IO::Traverse(string(pth), f);
670 }
672
674
675
679 template<typename _func>
680 YB_NONNULL(1) void
681 TraverseChildren(const char* path, _func f)
682 {
683 IO::Traverse(path, [f](NodeCategory c, NativePathView npv)
684 ynoexcept_spec(f(c, npv)){
685 if(!PathTraits::is_parent(npv))
686 f(c, npv);
687 });
688 }
690 template<typename _func>
691 void
692 TraverseChildren(const string& path, _func f)
693 {
694 IO::TraverseChildren(path.c_str(), f);
695 }
697 template<typename _func>
699 inline void
700 TraverseChildren(const Path& pth, _func f)
701 {
702 IO::TraverseChildren(string(pth), f);
703 }
705
713 template<typename _func, typename... _tParams>
714 auto
715 TraverseTree(_func f, const Path& dst, const Path& src, _tParams&&... args)
716 -> decltype(f(std::declval<Path&>(), std::declval<Path&>(),
717 std::forward<_tParams>(args)...))
718 {
719 EnsureDirectory(dst);
720 TraverseChildren(src, [&](NodeCategory c, NativePathView npv){
721 const String name(npv);
722 // NOTE: Allowed to be modified.
723 auto dname(dst / name), sname(src / name);
724
725 // XXX: Blocked. 'yforward' cause G++ 5.2 crash: internal compiler
726 // error: Aborted (program cc1plus) or crash silently.
727 return bool(c & NodeCategory::Directory)
728 ? IO::TraverseTree(f, dname, sname, std::forward<_tParams>(args)...)
729 : f(dname, sname, std::forward<_tParams>(args)...);
730 });
731 }
732
733
735
736
740 using CopyFileHandler = function<void(FileDescriptor, FileDescriptor)>;
741
743
744 const auto PreserveModificationTime(
746 ystdex::bind_forward(&FileDescriptor::SetModificationTime,
747 &FileDescriptor::GetModificationTime));
749 const auto PreserveModificationAndAccessTime(
750 ystdex::bind_forward(&FileDescriptor::SetModificationAndAccessTime,
751 &FileDescriptor::GetModificationAndAccessTime));
753
754
769 YF_API void
770 CopyFile(UniqueFile, FileDescriptor);
772
773
777 YF_API YB_NONNULL(2) void
778 CopyFile(UniqueFile, const char*);
780
781
783 YF_API YB_NONNULL(1) void
785 CopyFile(const char*, FileDescriptor, mode_t = DefaultPMode(),
786 size_t = 1, bool = {});
788 YF_API YB_NONNULL(1, 2) void
789 CopyFile(const char*, const char*, mode_t = DefaultPMode(), size_t = 1,
790 bool = {});
792
799 YF_API YB_NONNULL(1) void
800 CopyFile(const char*, FileDescriptor, CopyFileHandler, mode_t = DefaultPMode(),
801 size_t = 1, bool = {});
802 YF_API YB_NONNULL(1, 2) void
803 CopyFile(const char*, const char*, CopyFileHandler, mode_t = DefaultPMode(),
804 size_t = 1, bool = {});
806
807
808
809
811
812
818 template<typename... _tParams>
819 void
820 CopyTree(const Path& dst, const Path& src, _tParams&&... args)
821 {
822 // XXX: Blocked. 'yforward' may cause G++ 5.2 silent crash.
823 IO::TraverseTree([](const Path& dname, const Path& sname,
824 _tParams&&... fargs){
825 IO::CopyFile(string(dname).c_str(), string(sname).c_str(),
826 std::forward<_tParams>(fargs)...);
827 }, dst, src, std::forward<_tParams>(args)...);
828 }
829
831
832
837 YF_API void
838 ClearTree(const Path&);
839 inline PDefH(void, ClearTree, const string& pth)
840 ImplRet(ClearTree(Path(pth)))
842
844
845 inline PDefH(void, DeleteTree, const Path& pth)
846 ImplExpr(ClearTree(pth), IO::Remove(string(pth).c_str()))
848 inline PDefH(void, DeleteTree, const string& pth)
849 ImplExpr(DeleteTree(Path(pth)))
851
852
858 YF_API void
859 ListFiles(const Path&, vector<String>&);
861
862
868 YF_API NodeCategory
869 ClassifyNode(const Path&);
870
871 } // namespace IO;
872
873 } // namespace YSLib;
874
875 #endif
876
YSLib::IO::Path
路径。
Definition: YSLib/Service/FileSystem.h:217
YB_ATTR_nodiscard
#define YB_ATTR_nodiscard
标记返回值不被忽略的属性。
Definition: ydef.h:715
ystdex::fseq::front
identity< _type > front(empty_base< _type, _types... >)
Definition: variadic.hpp:74
CHRLib::e
const char const char * e
Definition: CharacterProcessing.h:112
Path
IO::Path Path
Definition: Initialization.cpp:116
YSLib::IO::CopyTree
void CopyTree(const Path &dst, const Path &src, _tParams &&... args)
复制目录树。
Definition: YSLib/Service/FileSystem.h:820
x
const EncapsulationBase & x
Definition: NPLA1Forms.cpp:1536
YSLib::swap
void swap(ValueNode &x, ValueNode &y) ynothrowv
Definition: ValueNode.cpp:95
path.hpp
抽象路径模板。
size
size_t size
Definition: memory_resource.cpp:295
YSLib::IO::Path::AsStringArg
String AsStringArg(_tParam &&arg)
Definition: YSLib/Service/FileSystem.h:362
YSLib::IO::Path::DefDeCopyCtor
DefDeCopyCtor(Path) DefDeMoveCtor(Path) DefDeDtor(Path) DefDeCopyAssignment(Path) DefDeMoveAssignment(Path) PDefHOp(Path &
复制构造：默认实现。
ystdex::bind_forward
auto bind_forward(_func &&f, _func2 &&f2, _tParams &&... args) -> decltype(ystdex::bind1(std::forward< decltype(f)>(f), std::bind(std::forward< decltype(f2)>(f2), std::placeholders::_2, std::forward< decltype(args)>(args)...)))
复合调用 ystdex::bind1 和 std::placeholders::_2 以实现值的设置。
Definition: functional.hpp:77
ystdex::path_traits< void >::is_parent
static bool is_parent(const _tString &str)
Definition: path.hpp:91
YSLib::IO::GetExtensionOf
_tString GetExtensionOf(const _tString &fname)
取扩展名。
Definition: YSLib/Service/FileSystem.h:476
CHRLib::c
c
Definition: CharacterProcessing.h:84
yconstexpr
#define yconstexpr
指定编译时常量表达式。
Definition: ydef.h:1072
YB_PURE
#define YB_PURE
指示函数或函数模板实例为纯函数。
Definition: ydef.h:919
platform::mode_t
::mode_t mode_t
文件模式类型。
Definition: FileIO.h:116
ystdex::cpp2017::basic_string
Definition: string.hpp:77
ystdex::split
void split(_tIn b, _tIn e, _fPred is_delim, _fInsert insert)
以指定分隔符分割序列。
Definition: algorithm.hpp:291
ystdex::cpp2017::basic_string_view
Definition: string_view.hpp:95
YSLib::IO::ClearTree
YF_API void ClearTree(const Path &)
清空参数指定路径的目录树内容。
Definition: YSLib/Service/FileSystem.cpp:202
platform::FileDescriptor::SetModificationAndAccessTime
void SetModificationAndAccessTime(array< FileTime, 2 >) const
设置修改和访问时间。
Definition: FileIO.cpp:581
DefDeMoveCtor
#define DefDeMoveCtor(_t)
Definition: YBaseMacro.h:167
YSLib::IO::_tTraits
const string &path const String &path class class _tTraits
Definition: YSLib/Service/FileSystem.h:582
platform::FileDescriptor
文件描述符包装类。
Definition: FileIO.h:149
ystdex::cpp2014::enable_if_t
typename enable_if< _bCond, _type >::type enable_if_t
Definition: meta.hpp:199
ystdex::string_view_t
basic_string_view< typename _tString::value_type > string_view_t
取字符串类类型的值类型对应的字符串视图类型。
Definition: string_view.hpp:450
YSLib::IO::YB_NONNULL
YF_API YB_NONNULL(1) UniqueFile OpenFile(const char *
打开文件。
Definition: File.h:62
YSLib::IO::ParsePath
_tPath ParsePath(_tStringView sv, _tPath res={})
Definition: YSLib/Service/FileSystem.h:191
ystdex::path::iterator
typename base::iterator iterator
Definition: path.hpp:284
ystdex::normalize
auto normalize(_tString &str) -> decltype(str.resize(ystdex::ntctslen(str.c_str())))
NTCTS 正规化：保留空字符之前的字符。
Definition: string.hpp:1245
CHRLib::CharSet::Encoding
Encoding
字符流编码标识。
Definition: Encoding.h:59
ynoexcept_spec
#define ynoexcept_spec(...)
表达式 noexcept 异常规范。
Definition: ydef.h:1181
ystdex::path
一般路径模板。
Definition: path.hpp:268
YF_API
#define YF_API
Definition: Platform.h:56
YSLib::IO::NormalizeDirectoryPathTail
ystdex::decay_t< _tString > NormalizeDirectoryPathTail(_tString &&str, typename ystdex::string_traits< _tString >::const_pointer tail=&ystdex::to_array< typename ystdex::string_traits< _tString >::value_type >("/\\")[0])
目录路径结束正规化：保证以一个分隔符结束。
Definition: YSLib/Service/FileSystem.h:136
YSLib::IO::TraverseTree
const string &path const String &path class class class class typename _tParams auto TraverseTree(_func f, const Path &dst, const Path &src, _tParams &&... args) -> decltype(f(std::declval< Path & >(), std::declval< Path & >(), std::forward< _tParams >(args)...))
Definition: YSLib/Service/FileSystem.h:715
platform::FetchLimit
YF_API size_t FetchLimit(SystemOption) ynothrow
取限制配置。
Definition: YCommon.cpp:121
CHRLib::f
f(d, s)
ystdex::path_traits
路径特征。
Definition: path.hpp:83
YSLib::IO::bool
YF_API const char *YF_API bool
Definition: YSLib/Service/FileSystem.h:786
ystdex::cpp2014::cbegin
auto cbegin(const _tRange &c) -> decltype(ystdex::begin(c))
Definition: range.hpp:418
YSLib::IO::PathTraits::has_root_path
static yconstfn bool has_root_path(const _tString &str) ynothrow
Definition: YSLib/Service/FileSystem.h:114
ystdex::path_traits< void >::is_self
static bool is_self(const _tString &str)
Definition: path.hpp:108
ystdex::cpp2014::cend
auto cend(const _tRange &c) -> decltype(ystdex::end(c))
Definition: range.hpp:427
ystdex::cpp2014::decay_t
typename decay< _type >::type decay_t
Definition: meta.hpp:196
YSLib::IO::PreserveModificationTime
const auto PreserveModificationTime(ystdex::bind_forward(&FileDescriptor::SetModificationTime, &FileDescriptor::GetModificationTime))
保持修改时间。
platform::UniqueFile
unique_ptr_from< FileDescriptor::Deleter > UniqueFile
Definition: FileIO.h:486
DefDeDtor
#define DefDeDtor(_t)
Definition: YBaseMacro.h:177
YSLib::YAssert
YAssert(!(v< Deref(a)), "Value less than lower bound found.")
YSLib::IO::_tString
const string &path const String &path class class class _tString
Definition: YSLib/Service/FileSystem.h:612
ystdex::dep_ops::dividable
_t< details::ops_seq< _type, _type2, _tOpt, details::ops_bin_id_seq< 3, 0, 1 > >> dividable
Definition: operators.hpp:302
ystdex::or_
逻辑或。
Definition: integral_constant.hpp:172
YSLib::IO::EnsureDirectory
EnsureDirectory
Definition: YSLib/Service/FileSystem.h:558
yforward
#define yforward(_expr)
根据参数类型使用 std::forward 转发对应参数。
Definition: ydef.h:1508
ystdex::string_traits::const_pointer
const value_type * const_pointer
Definition: string.hpp:802
YSLib::Drawing::src
src
Definition: YGDI.h:442
YSLib::Text::String
YSLib 标准字符串（使用 UCS-2 作为内部编码）。
Definition: YString.h:47
YSLib::IO::PathTraits
文件路径特征。
Definition: YSLib/Service/FileSystem.h:91
platform::SystemOption
SystemOption
系统配置选项。
Definition: YCommon.h:421
YSLib::IO::CopyFile
YF_API void CopyFile(UniqueFile, FileDescriptor)
复制文件。
Definition: YSLib/Service/FileSystem.cpp:158
ystdex::cpp2017::end
auto end(_tRange &c) -> decltype(c.end())
Definition: range.hpp:345
std
Definition: optional.h:982
YAssertNonnull
#define YAssertNonnull(_expr)
Definition: cassert.h:165
YSLib::IO::PDefH
PDefH(bool, IsAbsolute, const string &path) ImplRet(IsAbsolute(path.c_str())) inline PDefH(bool
判断路径表示绝对路径。
YSLib::IO::_tStringView
const string &path const String &path class _tStringView
Definition: YSLib/Service/FileSystem.h:581
YSLib::yimpl
YF_API yimpl(GUIApplication &) FetchGlobalInstance()
取全局应用程序实例。
YSLib::IO::Path::DefDeCtor
DefDeCtor(Path) explicit Path(ypath pth) ynothrow
无参数构造：默认实现。
Definition: YSLib/Service/FileSystem.h:230
ystdex::to_array
std::array< _type, _vN > to_array(const _tSrc &src)
转换指定参数为 std::array 对象。
Definition: array.hpp:92
YSLib::IO::MakeNormalizedAbsolute
Path MakeNormalizedAbsolute(const Path &pth, size_t init_size)
Definition: YSLib/Service/FileSystem.cpp:60
ystdex::find_suffix
_tString find_suffix(const _tString &str, _tParams &&... args)
取后缀子字符串。
Definition: string.hpp:1538
ystdex::dep_ops::totally_ordered
details::flat_ops< _type, _type2, _tOpt, less_than_comparable, equality_comparable > totally_ordered
Definition: operators.hpp:389
YSLib::IO::ParsePathWith
_tPath ParsePathWith(_tStringView sv, _func f, _tPath res={})
解析字符串为路径。
Definition: YSLib/Service/FileSystem.h:165
ystdex::path::traits_type
_tTraits traits_type
Definition: path.hpp:279
platform::FileDescriptor::SetModificationTime
void SetModificationTime(FileTime) const
设置修改时间。
Definition: FileIO.cpp:568
platform_ex::Windows::Directory
@ Directory
Definition: Win32/include/YCLib/MinGW32.h:466
platform::containers::vector
std::vector< _type, _tAlloc > vector
Definition: Container.h:102
YSLib::UI::y
SPos SPos y
Definition: YWidget.cpp:44
ystdex::to_string
std::string to_string(const std::thread::id &)
转换 thread::id 为字符串表示。
YSLib::path
YB_ATTR_nodiscard YF_API const char * path
Definition: Initialization.h:116
ystdex::cpp2017::u16string_view
basic_string_view< char16_t > u16string_view
Definition: string_view.hpp:438
DefDeCopyAssignment
#define DefDeCopyAssignment(_t)
Definition: YBaseMacro.h:186
YSLib::IO::ListFiles
void ListFiles(const Path &pth, vector< String > &lst)
Definition: YSLib/Service/FileSystem.cpp:214
YSLib
YSLib 命名空间。
Definition: AndroidHost.h:46
CHRLib::CS_Default
yconstexpr const Encoding CS_Default(CharSet::UTF_8)
默认字符编码。
YModules.h
YSLib 用户界面模块配置文件。
ystdex::exclude_self_t
enable_if_t<!is_same_param< _tSelected, _tParam >::value, _type > exclude_self_t
排除选择类型的特定参数的重载。
Definition: meta.hpp:865
YSLib::str
const char * str
Definition: YException.cpp:60
YSLib::ynothrow
YB_PURE const _type size_t n ynothrow
Definition: YCoreUtilities.h:169
ystdex::string_length
size_t string_length(const _tChar *str)
计算字符串长度。
Definition: string.hpp:1142
NPL::A1::name
const char * name
Definition: NPLA1.h:1876
platform::tail
_tString ystdex::string_traits< _tString >::const_pointer tail
Definition: YCLib/FileSystem.h:465
CHRLib::char16_t
YB_ATTR_nodiscard YB_PURE char16_t((*c_ptr<< CHAR_BIT)|c_ptr[1])) YB_ATTR_nodiscard YB_PURE inline PDefH(char16_t
取 c_ptr 指向的小端序双字节字符。
ystdex
<memory> 特性测试宏。
Definition: ydef.h:1262
YSLib::IO::Path::Path
Path(_type &&arg)
Definition: YSLib/Service/FileSystem.h:245
ystdex::path::const_iterator
typename base::const_iterator const_iterator
Definition: path.hpp:285
YSLib::IO::IsAbsolute
IsAbsolute
Definition: YSLib/Service/FileSystem.h:62
ystdex::string_traits::value_type
remove_cvref_t< decltype(std::declval< string_type >()[0])> value_type
Definition: string.hpp:790
YSLib::_tParams
YB_ATTR_nodiscard YB_PURE typename _tParams
Definition: ValueNode.h:1294
YSLib::IO::DeleteTree
DeleteTree
Definition: YSLib/Service/FileSystem.h:845
NPL::c_str
YF_API const char src c_str())) YF_API void InstallDirectory(const string &
安装目录：复制目录树。
Definition: Dependency.h:140
platform::FetchSeparator
YB_STATELESS yconstfn _tChar FetchSeparator() ynothrow
Definition: YCLib/FileSystem.h:93
DefCvt
#define DefCvt(_q, _t,...)
Definition: YBaseMacro.h:206
platform::FileDescriptor::GetModificationTime
YB_ATTR_nodiscard FileTime GetModificationTime() const
取修改时间。
Definition: FileIO.cpp:464
DefGetter
#define DefGetter(_q, _t, _n,...)
Definition: YBaseMacro.h:241
YSLib::IO::mode_t
YF_API mode_t
Definition: File.h:51
CHRLib::enc
enc
Definition: CharacterProcessing.h:84
ystdex::path::value_type
typename _tSeqCon::value_type value_type
Definition: path.hpp:277
YSLib::IO::PreserveModificationAndAccessTime
const auto PreserveModificationAndAccessTime(ystdex::bind_forward(&FileDescriptor::SetModificationAndAccessTime, &FileDescriptor::GetModificationAndAccessTime))
保持修改和访问时间。
YSLib::IO::ypath
ystdex::path< vector< String >, PathTraits > ypath
Definition: YSLib/Service/FileSystem.h:205
YSLib::IO::Path::Path
Path(std::initializer_list< _tElem > il)
Definition: YSLib/Service/FileSystem.h:261
YSLib::IO::CopyFileHandler
function< void(FileDescriptor, FileDescriptor)> CopyFileHandler
复制文件处理器：通知文件复制事件。
Definition: YSLib/Service/FileSystem.h:740
YSLib::IO::PathTraits::has_root_name
static yconstfn bool has_root_name(const _tString &str) ynothrow
Definition: YSLib/Service/FileSystem.h:121
platform::FetchCurrentWorkingDirectory
YB_ATTR_nodiscard basic_string< _tChar > FetchCurrentWorkingDirectory(size_t init)
尝试按指定的起始缓冲区大小取当前工作目录的路径。
Definition: FileIO.h:1222
YSLib::IO::MaxPathLength
yconstexpr const size_t MaxPathLength(yimpl(1<< 10))
默认目录路径长度。
const
const Decapsulate const Decapsulate &y ynothrow ContextNode &ctx const
Definition: NPLA1Forms.cpp:1629
YSLib::IO::ImplRet
const String &path ImplRet(IsAbsolute(path.GetMBCS())) template< typename _type > inline bool IsRelative(const _type &arg)
判断路径表示相对路径（包括空路径）。
Definition: YSLib/Service/FileSystem.h:63
YSLib::IO::PathTraits::IsDelimiter
static yconstfn bool IsDelimiter(_tChar c) ynothrow
Definition: YSLib/Service/FileSystem.h:97
YSLib::IO::Path::Path
Path(_type &&arg, Text::Encoding enc)
Definition: YSLib/Service/FileSystem.h:251
NPL::dst
YF_API const char src const string const char * dst
Definition: Dependency.h:96
DefDeMoveAssignment
#define DefDeMoveAssignment(_t)
Definition: YBaseMacro.h:191
ystdex::not_
逻辑非。
Definition: integral_constant.hpp:193
YSLib::IO::VerifyDirectory
VerifyDirectory
Definition: YSLib/Service/FileSystem.h:524
YSLib::IO::NativePathView
basic_string_view< HDirectory::NativeChar > NativePathView
Definition: YSLib/Service/FileSystem.h:45
platform::FileDescriptor::GetModificationAndAccessTime
YB_ATTR_nodiscard array< FileTime, 2 > GetModificationAndAccessTime() const
取修改和访问时间。
Definition: FileIO.cpp:469
YSLib::IO::PathTraits::is_absolute
static yconstfn bool is_absolute(const _tString &str) ynothrow
Definition: YSLib/Service/FileSystem.h:106
platform::IterateLink
YF_API bool IterateLink(string &, size_t &)
迭代访问链接：替换非空路径并按需减少允许链接计数。
Definition: YCLib/FileSystem.cpp:310
YSLib::args
YB_ATTR_nodiscard YB_PURE typename _tParams && args
Definition: ValueNode.h:1299
YSLib::IO::Path::Path
Path(_tIn first, _tIn last)
Definition: YSLib/Service/FileSystem.h:256
YSLib::IO::ClassifyNode
const Path &pth const string &pth vector< String > &YF_API NodeCategory ClassifyNode(const Path &)
按文件系统节点类别对路径分类。
Definition: YSLib/Service/FileSystem.cpp:225
yconstfn
#define yconstfn
指定编译时常量函数。
Definition: ydef.h:1073
ystdex::cpp2017::begin
auto begin(_tRange &c) -> decltype(c.begin())
Definition: range.hpp:323
ystdex::string_empty
bool string_empty(const _tChar *str)
判断字符串是否为空。
Definition: string.hpp:1110
NPL::_tParam
_tParam
Definition: NPLA.h:2367
platform::l
return l
Definition: YCLib/FileSystem.h:402
YSLib::IO::ImplExpr
const string &path ImplExpr(EnsureDirectory(path.c_str())) inline PDefH(void
ystdex::and_
逻辑操作元函数。
Definition: integral_constant.hpp:151
algorithm.hpp
泛型算法。
platform::DefaultPMode
YB_ATTR_nodiscard YF_API YB_STATELESS mode_t DefaultPMode() ynothrow
取默认权限。
Definition: FileIO.cpp:770