YSTest: FileSystem.h 源文件

YSTest PreAlpha_b800_20170810 The YSLib Test Project

- 首页
- 相关页面
- 模块
- 命名空间
- 类
- 文件

- 文件列表
- 文件成员

YSLib/Service/FileSystem.h
浏览该文件的文档.
1 /*
2 © 2010-2016 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 Remove;
33 #include YFM_YSLib_Core_YString
34 #include <ystdex/path.hpp> // for ystdex::path;
35
36 namespace YSLib
37 {
38
39 namespace IO
40 {
41
47 yconstexpr const size_t MaxPathLength(yimpl(1 << 10));
48
49
55 inline PDefH(bool, IsAbsolute, const string& path)
56 ImplRet(IsAbsolute(path.c_str()))
57 inline PDefH(bool, IsAbsolute, const String& path)
58 ImplRet(IsAbsolute(path.GetMBCS()))
60
66 template<typename _type>
67 inline bool
68 IsRelative(const _type& arg)
69 {
70 return !IsAbsolute(arg);
71 }
72
73
78 struct PathTraits
79 {
80 using value_type = YSLib::String;
81
82 template<typename _tChar>
83 static yconstfn bool
84 IsDelimiter(_tChar c) ynothrow
85 {
86 return IO::IsSeparator(c);
87 }
88
95 template<class _tPath, class _tString>
96 static void
97 AdjustForRoot(_tPath& pth, const _tString& sv)
98 {
99 using ystdex::cbegin;
100
101 if(!pth.empty() && IsRelative(pth.front()) && IsAbsolute(sv.data()))
102 pth.insert(cbegin(pth), {{}});
103 }
104
105 template<class _tString>
106 static yconstfn bool
107 is_parent(const _tString& str) ynothrow
108 {
109 using value_type = decltype(str[0]);
110
111 return ystdex::string_length(str) == 2 && str[0] == value_type('.')
112 && str[1] == value_type('.');
113 }
114
116 template<class _tString>
117 static yconstfn auto
118 is_root(const _tString& str) ynothrow
119 -> decltype(ystdex::string_length(str) == FetchRootNameLength(str))
120 {
121 return ystdex::string_length(str) == FetchRootNameLength(str);
122 }
124 template<typename _tChar, class _tTraits, class _tAlloc>
125 static bool
126 is_root(const basic_string<_tChar, _tTraits, _tAlloc>& str) ynothrow
127 {
128 return str.length() == FetchRootNameLength(str.c_str());
129 }
130
131 template<class _tString>
132 static yconstfn bool
133 is_self(const _tString& str) ynothrow
134 {
135 return
136 ystdex::string_length(str) == 1 && str[0] == decltype(str[0])('.');
137 }
138 };
139
140
146 template<class _tString>
147 inline ystdex::decay_t<_tString>
148 NormalizeDirectoryPathTail(_tString&& str, typename
149 ystdex::string_traits<_tString>::const_pointer tail = &ystdex::to_array<
150 typename ystdex::string_traits<_tString>::value_type>("/\\")[0])
151 {
152 using value_type = typename ystdex::string_traits<_tString>::value_type;
153
154 TrimTrailingSeperator(yforward(str), tail);
155 YAssert(str.empty() || !IsSeparator(str.back()), "Invalid path converted.");
156 str += FetchSeparator<value_type>();
157 return yforward(str);
158 }
159
160
168 template<class _tPath, typename _func,
169 class _tString = typename _tPath::value_type,
170 class _tTraits = typename _tPath::traits_type>
171 _tPath
172 ParsePath(const _tString& sv, _func f, _tPath res = {})
173 {
174 using ystdex::cbegin;
175 using ystdex::cend;
176
177 ystdex::split(cbegin(sv), cend(sv), [](decltype(*cbegin(sv)) c){
178 return _tTraits::IsDelimiter(c);
179 }, [&](decltype(cbegin(sv)) b, decltype(cend(sv)) e){
180 if(b != e)
181 {
182 f(res, b, e);
183 if(res.size() == 1)
184 _tTraits::AdjustForRoot(res,
185 typename _tPath::value_type(cbegin(sv), e));
186 }
187 });
188 return res;
189 }
190 template<class _tPath, class _tString = typename _tPath::value_type,
191 class _tTraits = typename _tPath::traits_type>
192 _tPath
193 ParsePath(const _tString& sv, _tPath res = {})
194 {
195 using ystdex::cbegin;
196 using ystdex::cend;
197
198 return IO::ParsePath<_tPath>(sv,
199 [](_tPath& pth, decltype(cbegin(sv)) b, decltype(cend(sv)) e){
200 pth.push_back(typename _tPath::value_type(b, e));
201 }, std::move(res));
202 }
204
205
207 using ypath = ystdex::path<vector<String>, PathTraits>;
208
209
214 class YF_API Path : private ypath, private ystdex::totally_ordered<Path>,
215 private ystdex::dividable<Path, String>, private ystdex::dividable<Path>
216 {
217 public:
218 using ypath::iterator;
219 using ypath::const_iterator;
221 using ypath::value_type;
223 using ypath::traits_type;
224
225 public:
229 DefDeCtor(Path)
231 explicit
232 Path(ypath pth) ynothrow
233 : ypath(std::move(pth))
234 {}
236 explicit
237 Path(const u16string& str) ynothrow
238 : Path(ParsePath<ypath>(str))
239 {}
241 template<typename _type, yimpl(typename = ystdex::enable_if_t<
242 !std::is_constructible<const u16string&, _type&&>::value>,
243 typename = ystdex::exclude_self_t<Path, _type>)>
244 explicit
245 Path(_type&& arg)
246 : ypath(ParsePath<ypath>(String(yforward(arg))))
247 {}
249 template<typename _type>
250 explicit
251 Path(_type&& arg, Text::Encoding enc)
252 : ypath(ParsePath<ypath>(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
278 DefDeCopyAssignment(Path)
283 DefDeMoveAssignment(Path)
284
286
287 PDefHOp(Path&, /=, const String& fname)
289 ImplRet(GetBaseRef() /= fname, *this)
290 PDefHOp(Path&, /=, const Path& pth)
291 ImplRet(GetBaseRef() /= pth, *this)
293
294 friend PDefHOp(bool, ==, const Path& x, const Path& y)
295 ImplRet(x.GetBase() == y.GetBase())
296
297 friend PDefHOp(bool, <, const Path& x, const Path& y)
298 ImplRet(x.GetBase() < y.GetBase())
299
305 explicit
306 DefCvt(const, String, GetLeafString())
311 explicit
312 DefCvt(const, string, String(*this).GetMBCS())
313
315 DefGetter(const ynothrow, const ypath&, Base, *this)
317 DefGetter(ynothrow, ypath&, BaseRef, *this)
319
320 PDefH(String, GetLeafString,
322 char16_t delimiter = FetchSeparator<char16_t>()) const
323 ImplRet(ystdex::to_string(GetBase(), {delimiter}))
328 String
329 GetString(char16_t = FetchSeparator<char16_t>()) const;
331
335 PDefH(void, Normalize, )
336 ImplExpr(ystdex::normalize(*this))
337
345 String
346 Verify(char16_t = FetchSeparator<char16_t>()) const;
351 PDefH(string, VerifyAsMBCS,
352 char16_t delimiter = char16_t(FetchSeparator<char16_t>()),
353 Text::Encoding enc = Text::CS_Default) const
354 ImplRet(Verify(delimiter).GetMBCS(enc))
355
357
358 using ypath::back;
359
360 using ypath::begin;
361
362 using ypath::cbegin;
363
364 using ypath::clear;
365
366 using ypath::cend;
367
368 using ypath::empty;
369
370 using ypath::end;
371
372 using ypath::erase;
373
375 using ypath::filter_self;
376
377 using ypath::front;
378
379 using ypath::insert;
380
381 using ypath::is_absolute;
382
383 using ypath::is_relative;
384
386 using ypath::max_size;
387
389 using ypath::merge_parents;
390
392 using ypath::pop_back;
393
395 using ypath::push_back;
396
398 using ypath::size;
399
401
402 friend PDefH(void, swap, Path& x, ypath& y)
403 ImplExpr(y.swap(x));
404 friend PDefH(void, swap, ypath& x, Path& y)
405 ImplExpr(x.swap(y));
406 friend PDefH(void, swap, Path& x, Path& y)
407 ImplExpr(y.GetBaseRef().swap(x))
409
411 friend PDefH(String, to_string, const Path& pth)
412 ImplRet(to_string(pth.GetBase(), {FetchSeparator<char16_t>()}))
414 };
415
416
423 template<class _tString>
425 _tString
426 GetExtensionOf(const _tString& fname)
427 {
428 return ystdex::find_suffix(fname, typename _tString::value_type('.'));
429 }
431 inline PDefH(String, GetExtensionOf, const Path& pth)
432 ImplRet(pth.empty() ? String() : GetExtensionOf(pth.back()))
434
435
437
438
442 inline PDefH(bool, IsAbsolute, const Path& pth)
443 ImplRet(!pth.empty() && IsAbsolute(pth.GetString()))
444
455 YF_API Path
456 MakeNormalizedAbsolute(const Path&, size_t = MaxPathLength);
458
459
466 YF_API YB_NONNULL(1) bool
467 VerifyDirectory(const char*);
469 YF_API YB_NONNULL(1) bool
470 VerifyDirectory(const char16_t*);
471 inline PDefH(bool, VerifyDirectory, const string& path)
472 ImplRet(VerifyDirectory(path.c_str()))
474 inline PDefH(bool, VerifyDirectory, const u16string& path)
475 ImplRet(VerifyDirectory(path.c_str()))
476 inline PDefH(bool, VerifyDirectory, const String& path)
477 ImplRet(VerifyDirectory(path.c_str()))
478 inline PDefH(bool, VerifyDirectory, const Path& pth)
479 ImplRet(!pth.empty() && VerifyDirectory(pth.GetString()))
481
487 template<class _tString>
488 inline ystdex::decay_t<_tString>
489 VerifyDirectoryPathTail(_tString&& str)
490 {
491 if(!(str.empty() || VerifyDirectory(str)))
492 str.pop_back();
493 return yforward(str);
494 }
495
496
504 YF_API void
505 EnsureDirectory(const Path&);
506 inline PDefH(void, EnsureDirectory, const char* path)
507 ImplExpr(EnsureDirectory(Path(path)))
508 inline PDefH(void, EnsureDirectory, const string& path)
509 ImplExpr(EnsureDirectory(path.c_str()))
510 inline PDefH(void, EnsureDirectory, const String& path)
511 ImplExpr(EnsureDirectory(path.GetMBCS()))
513
514
529 template<class _tPath = Path, class _tString = typename _tPath::value_type,
530 class _tTraits = typename _tPath::traits_type>
531 _tPath
532 ResolvePathWithBase(const _tString& sv, _tPath base,
533 size_t n = FetchLimit(SystemOption::MaxSymlinkLoop))
534 {
535 using ystdex::cbegin;
536 using ystdex::cend;
537
538 return IO::ParsePath<_tPath>(sv,
539 [&](_tPath& pth, decltype(cbegin(sv)) b, decltype(cend(sv)) e){
540 pth /= typename _tPath::value_type(b, e);
541 if(pth.size() == 1)
542 _tTraits::AdjustForRoot(pth,
543 typename _tPath::value_type(cbegin(sv), e));
544
545 auto str(to_string(pth));
546
547 // XXX: This may be not efficient because underlying calls will resolve
548 // the path prefix repeatedly.
549 // FIXME: Blocked. TOCTTOU access.
550 if(IO::IterateLink(str, n))
551 {
552 // XXX: Handle absolute device path, etc?
553 if(IsAbsolute(str))
554 pth = IO::ParsePath<_tPath>(std::move(str));
555 else
556 {
557 // TODO: Check condition?
558 if(!pth.empty())
559 pth.pop_back();
560 pth /= str;
561 }
562 }
563 }, std::move(base));
564 }
565
570 template<class _tPath = Path, class _tString = typename _tPath::value_type,
571 class _tTraits = typename _tPath::traits_type>
572 _tPath
573 ResolvePath(const _tString& sv,
574 size_t n = FetchLimit(SystemOption::MaxSymlinkLoop),
575 size_t init_len = MaxPathLength)
576 {
577 return IO::ResolvePathWithBase(sv, IsAbsolute(sv.data()) ? _tPath()
578 : IO::ParsePath<_tPath>(FetchCurrentWorkingDirectory<typename
579 _tString::value_type>(init_len)), n);
580 }
582
583
589 template<typename _func>
590 void
591 Traverse(HDirectory& dir, _func f)
592 {
593 for(NativePathView npv : dir)
594 {
595 YAssert(!npv.empty(), "Empty name found.");
596 // TODO: Allow user code to specify filtering on self node?
597 if(!PathTraits::is_self(npv))
598 f(dir.GetNodeCategory(), npv);
599 }
600 }
602
603
605 template<typename _func>
607 inline YB_NONNULL(1) void
608 Traverse(const char* path, _func f)
609 {
610 // NOTE: Separators at end of path is allowed by %HDirectory::HDirectory.
611 HDirectory dir(path);
612
613 IO::Traverse(dir, f);
614 }
616 template<typename _func>
617 inline void
618 Traverse(const string& path, _func f)
619 {
620 IO::Traverse(path.c_str(), f);
621 }
623 template<typename _func>
624 inline void
625 Traverse(const Path& pth, _func f)
626 {
627 IO::Traverse(string(pth), f);
628 }
630
632
633
637 template<typename _func>
638 YB_NONNULL(1) void
639 TraverseChildren(const char* path, _func f)
640 {
641 IO::Traverse(path, [f](NodeCategory c, NativePathView npv)
642 ynoexcept_spec(f(c, npv)){
643 if(!PathTraits::is_parent(npv))
644 f(c, npv);
645 });
646 }
648 template<typename _func>
649 void
650 TraverseChildren(const string& path, _func f)
651 {
652 IO::TraverseChildren(path.c_str(), f);
653 }
655 template<typename _func>
657 inline void
658 TraverseChildren(const Path& pth, _func f)
659 {
660 IO::TraverseChildren(string(pth), f);
661 }
663
671 template<typename _func, typename... _tParams>
672 auto
673 TraverseTree(_func f, const Path& dst, const Path& src, _tParams&&... args)
674 -> decltype(f(std::declval<Path&>(), std::declval<Path&>(),
675 std::forward<_tParams>(args)...))
676 {
677 EnsureDirectory(dst);
678 TraverseChildren(src, [&](NodeCategory c, NativePathView npv){
679 const String name(npv);
680 // NOTE: Allowed to be modified.
681 auto dname(dst / name), sname(src / name);
682
683 // XXX: Blocked. 'yforward' cause G++ 5.2 crash: internal compiler
684 // error: Aborted (program cc1plus) or crash silently.
685 return bool(c & NodeCategory::Directory)
686 ? IO::TraverseTree(f, dname, sname, std::forward<_tParams>(args)...)
687 : f(dname, sname, std::forward<_tParams>(args)...);
688 });
689 }
690
691
693
694
699 using CopyFileHandler = std::function<void(FileDescriptor, FileDescriptor)>;
700
702
703 const auto PreserveModificationTime(ystdex::bind_forward(
705 &FileDescriptor::SetModificationTime, &FileDescriptor::GetModificationTime));
707 const auto PreserveModificationAndAccessTime(ystdex::bind_forward(
708 &FileDescriptor::SetModificationAndAccessTime,
709 &FileDescriptor::GetModificationAndAccessTime));
711
712
727 YF_API void
728 CopyFile(UniqueFile, FileDescriptor);
730
731 YF_API YB_NONNULL(2) void
733 CopyFile(UniqueFile, const char*);
735
736
738 YF_API YB_NONNULL(1) void
740 CopyFile(const char*, FileDescriptor, mode_t = DefaultPMode(),
741 size_t = 1, bool = {});
742 YF_API YB_NONNULL(1, 2) void
743 CopyFile(const char*, const char*, mode_t = DefaultPMode(), size_t = 1,
744 bool = {});
746
753 YF_API YB_NONNULL(1) void
754 CopyFile(const char*, FileDescriptor, CopyFileHandler, mode_t = DefaultPMode(),
755 size_t = 1, bool = {});
756 YF_API YB_NONNULL(1, 2) void
757 CopyFile(const char*, const char*, CopyFileHandler, mode_t = DefaultPMode(),
758 size_t = 1, bool = {});
760
761
762
763
765
766
772 template<typename... _tParams>
773 void
774 CopyTree(const Path& dst, const Path& src, _tParams&&... args)
775 {
776 // XXX: Blocked. 'yforward' may cause G++ 5.2 silent crash.
777 IO::TraverseTree([](const Path& dname, const Path& sname,
778 _tParams&&... fargs){
779 IO::CopyFile(string(dname).c_str(), string(sname).c_str(),
780 std::forward<_tParams>(fargs)...);
781 }, dst, src, std::forward<_tParams>(args)...);
782 }
783
785
786
791 YF_API void
792 ClearTree(const Path&);
793 inline PDefH(void, ClearTree, const string& pth)
794 ImplRet(ClearTree(Path(pth)))
796
798
799 inline PDefH(void, DeleteTree, const Path& pth)
800 ImplExpr(ClearTree(pth), Remove(string(pth).c_str()))
802 inline PDefH(void, DeleteTree, const string& pth)
803 ImplExpr(DeleteTree(Path(pth)))
805
806
812 YF_API void
813 ListFiles(const Path&, vector<String>&);
815
816
822 YF_API NodeCategory
823 ClassifyNode(const Path&);
824
825 } // namespace IO;
826
827 } // namespace YSLib;
828
829 #endif
830
DefDeCopyAssignment
#define DefDeCopyAssignment(_t)
Definition: YBaseMacro.h:186
platform::FileDescriptor
文件描述符包装类。
Definition: FileIO.h:146
ystdex::basic_string_view
Definition: string_view.hpp:49
NPL::dst
YF_API const char src const string const char * dst
Definition: Dependency.h:95
platform::HDirectory
目录句柄：表示打开的目录和内容迭代状态。
Definition: YCLib/FileSystem.h:562
yconstfn
#define yconstfn
指定编译时常量函数。
Definition: ydef.h:680
YSLib::IO::Path::YB_NONNULL
PDefH(String, GetExtensionOf, const Path &pth) ImplRet(pth.empty()?String() YF_API YB_NONNULL(1) bool VerifyDirectory(const char *)
判断路径表示绝对路径。
Definition: YSLib/Service/FileSystem.h:466
YModules.h
platform::FileDescriptor::SetModificationTime
void SetModificationTime(FileTime) const
设置修改时间。
Definition: FileIO.cpp:571
platform::FetchLimit
YF_API size_t FetchLimit(SystemOption) ynothrow
取限制配置。
Definition: YCommon.cpp:69
YSLib::IO::mode_t
YF_API mode_t
Definition: File.h:51
YSLib
YSLib 命名空间。
Definition: AndroidHost.h:45
platform::containers::u16string
basic_string< char16_t > u16string
Definition: Container.h:103
ystdex::to_string
std::string to_string(const std::thread::id &)
转换 thread::id 为字符串表示。
ystdex::dep_ops::totally_ordered
details::flat_ops< _type, _type2, _tOpt, less_than_comparable, equality_comparable > totally_ordered
Definition: operators.hpp:367
platform::tail
_tString ystdex::string_traits< _tString >::const_pointer tail
Definition: YCLib/FileSystem.h:286
ystdex::string_traits::const_pointer
const value_type * const_pointer
Definition: string.hpp:70
path.hpp
抽象路径模板。
YSLib::IO::PathTraits::value_type
YSLib::String value_type
Definition: YSLib/Service/FileSystem.h:80
platform::FileDescriptor::GetModificationAndAccessTime
array< FileTime, 2 > GetModificationAndAccessTime() const
取修改和访问时间。
Definition: FileIO.cpp:472
YSLib::UI::y
SPos SPos y
Definition: YWidget.cpp:44
NPL::x
const TermNode &term ynothrow const TermNode &term ynothrow const TermNode &term ynothrow TermNode &term const TermNode &term ValueNode &node const ValueNode &node const _type & x
Definition: SContext.h:94
YSLib::IO::ParsePath
_tPath ParsePath(const _tString &sv, _func f, _tPath res={})
解析字符串为路径。
Definition: YSLib/Service/FileSystem.h:172
ystdex::container_adaptor::value_type
typename container_type::value_type value_type
满足容器要求。
Definition: container.hpp:62
CHRLib::f
f(d, s)
YSLib::IO::EnsureDirectory
void EnsureDirectory(const Path &pth)
Definition: YSLib/Service/FileSystem.cpp:106
ynoexcept_spec
#define ynoexcept_spec(...)
表达式 noexcept 异常规范。
Definition: ydef.h:794
YSLib::IO::PDefH
PDefH(bool, IsAbsolute, const string &path) ImplRet(IsAbsolute(path.c_str())) inline PDefH(bool
判断路径表示绝对路径。
Text
YSLib::IO::ListFiles
void ListFiles(const Path &pth, vector< String > &lst)
Definition: YSLib/Service/FileSystem.cpp:193
DefDeMoveCtor
#define DefDeMoveCtor(_t)
Definition: YBaseMacro.h:167
NPL::c_str
YF_API const char src c_str())) YF_API void InstallDirectory(const string &
安装目录：复制目录树。
Definition: Dependency.h:131
ystdex::cpp2014::enable_if_t
typename enable_if< _bCond, _type >::type enable_if_t
Definition: type_traits.hpp:343
YSLib::IO::NativePathView
basic_string_view< HDirectory::NativeChar > NativePathView
Definition: YAdaptor.h:450
YSLib::IO::ImplExpr
const Path &pth ImplExpr(ClearTree(pth), Remove(string(pth).c_str())) inline PDefH(void
ystdex::cpp2014::cend
auto cend(const _tRange &c) -> decltype(std::end(c))
Definition: range.hpp:87
platform::UniqueFile
unique_ptr_from< FileDescriptor::Deleter > UniqueFile
Definition: FileIO.h:464
platform::FetchCurrentWorkingDirectory
basic_string< _tChar > FetchCurrentWorkingDirectory(size_t init)
尝试按指定的起始缓冲区大小取当前工作目录的路径。
Definition: FileIO.h:1135
YSLib::IO::DeleteTree
DeleteTree
Definition: YSLib/Service/FileSystem.h:799
CHRLib::args
_tParams && args
Definition: CharacterProcessing.h:538
yconstexpr
#define yconstexpr
指定编译时常量表达式。
Definition: ydef.h:679
ystdex::path::const_iterator
typename base::const_iterator const_iterator
Definition: path.hpp:142
YSLib::IO::CopyTree
void CopyTree(const Path &dst, const Path &src, _tParams &&...args)
复制目录树。
Definition: YSLib/Service/FileSystem.h:774
YSLib::IO::FileDescriptor
YF_API const char *YF_API FileDescriptor
Definition: YSLib/Service/FileSystem.h:740
platform::FetchSeparator
yconstfn YB_STATELESS _tChar FetchSeparator() ynothrow
Definition: YCLib/FileSystem.h:90
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:646
ystdex::cpp2011::end
_type * end(_type(&&array)[_vN])
Definition: range.hpp:54
YSLib::IO::CopyFileHandler
std::function< void(FileDescriptor, FileDescriptor)> CopyFileHandler
复制文件处理器：通知文件复制事件。
Definition: YSLib/Service/FileSystem.h:699
YSLib::YAssert
YAssert(!(v< Deref(a)),"Value less than lower bound found.")
YSLib::IO::ClearTree
YF_API void ClearTree(const Path &)
路径指向的不是一个目录或删除失败。
Definition: YSLib/Service/FileSystem.cpp:181
ystdex::container_adaptor::base
container_type base
Definition: container.hpp:57
ystdex::path::traits_type
_tTraits traits_type
Definition: path.hpp:136
ystdex::string_length
size_t string_length(const _type *str)
计算字符串长度。
Definition: string.hpp:364
YSLib::IO::Path::Path
Path(_tIn first, _tIn last)
Definition: YSLib/Service/FileSystem.h:256
ystdex::path::value_type
typename _tSeqCon::value_type value_type
Definition: path.hpp:134
platform::FileDescriptor::GetModificationTime
FileTime GetModificationTime() const
取修改时间。
Definition: FileIO.cpp:467
YSLib::IO::VerifyDirectory
bool VerifyDirectory(const char *path)
Definition: YSLib/Service/FileSystem.cpp:95
DefDeMoveAssignment
#define DefDeMoveAssignment(_t)
Definition: YBaseMacro.h:191
ystdex::find_suffix
_tString find_suffix(const _tString &str, _tParams &&...args)
取后缀子字符串。
Definition: string.hpp:760
ystdex::path::iterator
typename base::iterator iterator
Definition: path.hpp:141
YSLib::IO::ClassifyNode
const Path &pth const string &pth vector< String > &YF_API NodeCategory ClassifyNode(const Path &)
按文件系统节点类别对路径分类。
Definition: YSLib/Service/FileSystem.cpp:204
YSLib::IO::GetExtensionOf
_tString GetExtensionOf(const _tString &fname)
取扩展名。
Definition: YSLib/Service/FileSystem.h:426
ystdex::cpp2014::decay_t
typename decay< _type >::type decay_t
Definition: type_traits.hpp:340
YSLib::IO::Path::Path
Path(const u16string &str) ynothrow
Definition: YSLib/Service/FileSystem.h:237
ystdex::cpp2014::cbegin
auto cbegin(const _tRange &c) -> decltype(std::begin(c))
Definition: range.hpp:79
IO
ystdex
特性测试宏。
Definition: ydef.h:822
DefDeDtor
#define DefDeDtor(_t)
Definition: YBaseMacro.h:177
ystdex::normalize
auto normalize(_tString &str) -> decltype(str.resize(ystdex::ntctslen(str.c_str())))
NTCTS 正规化：保留空字符之前的字符。
Definition: string.hpp:467
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:673
YSLib::IO::PathTraits::IsDelimiter
static yconstfn bool IsDelimiter(_tChar c) ynothrow
Definition: YSLib/Service/FileSystem.h:84
YSLib::IO::PathTraits::AdjustForRoot
static void AdjustForRoot(_tPath &pth, const _tString &sv)
调整绝对路径的第一组件。
Definition: YSLib/Service/FileSystem.h:97
YSLib::IO::PathTraits::is_root
static bool is_root(const basic_string< _tChar, _tTraits, _tAlloc > &str) ynothrow
Definition: YSLib/Service/FileSystem.h:126
YSLib::IO::bool
YF_API const char *YF_API bool
Definition: YSLib/Service/FileSystem.h:741
YF_API
#define YF_API
Definition: Platform.h:56
YSLib::yimpl
YF_API yimpl(GUIApplication &) FetchGlobalInstance()
取全局应用程序实例。
CHRLib::enc
enc
Definition: CharacterProcessing.h:81
ystdex::path
一般路径模板。
Definition: path.hpp:123
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:148
YSLib::IO::PathTraits::is_parent
static yconstfn bool is_parent(const _tString &str) ynothrow
Definition: YSLib/Service/FileSystem.h:107
YSLib::IO::PreserveModificationTime
const auto PreserveModificationTime(ystdex::bind_forward(&FileDescriptor::SetModificationTime,&FileDescriptor::GetModificationTime))
保持修改时间。
YSLib::ynothrow
YB_PURE const _type size_t n ynothrow
Definition: YCoreUtilities.h:168
platform::FileDescriptor::SetModificationAndAccessTime
void SetModificationAndAccessTime(array< FileTime, 2 >) const
设置修改和访问时间。
Definition: FileIO.cpp:584
ystdex::fseq::front
identity< _type > front(empty_base< _type, _types... >)
Definition: variadic.hpp:74
CHRLib::e
const char const char * e
Definition: CharacterProcessing.h:109
YSLib::IO::MaxPathLength
yconstexpr const size_t MaxPathLength(yimpl(1<< 10))
默认目录路径长度。
ystdex::to_array
std::array< _type, _vN > to_array(const _tSrc &src)
转换指定参数为 std::array 对象。
Definition: array.hpp:87
ystdex::exclude_self_t
enable_if_t<!is_same< _tClass &, decay_t< _tParam > & >::value, _type > exclude_self_t
移除选择类类型的特定重载避免构造模板和复制/转移特殊成员函数冲突。
Definition: type_traits.hpp:748
std
Definition: memory.hpp:1183
DefGetter
#define DefGetter(_q, _t, _n,...)
Definition: YBaseMacro.h:241
DefCvt
#define DefCvt(_q, _t,...)
Definition: YBaseMacro.h:206
YSLib::IO::CopyFile
YF_API void CopyFile(UniqueFile, FileDescriptor)
复制文件。
Definition: YSLib/Service/FileSystem.cpp:137
YSLib::IO::Path::Path
Path(std::initializer_list< _tElem > il)
Definition: YSLib/Service/FileSystem.h:261
YSLib::IO::ImplRet
const String &path ImplRet(IsAbsolute(path.GetMBCS())) template< typename _type > inline bool IsRelative(const _type &arg)
判断路径表示相对路径（包括空路径）。
Definition: YSLib/Service/FileSystem.h:58
ystdex::split
void split(_tIn b, _tIn e, _fPred is_delim, _fInsert insert)
以指定分隔符分割序列。
Definition: algorithm.hpp:215
CHRLib::CS_Default
yconstexpr const Encoding CS_Default(CharSet::UTF_8)
默认字符编码。
DefDeCopyCtor
#define DefDeCopyCtor(_t)
Definition: YBaseMacro.h:162
YSLib::IO::size_t
YF_API const char *YF_API size_t
Definition: YSLib/Service/FileSystem.h:741
YSLib::UI::name
yconstfn const string & name
Definition: Loader.h:130
YSLib::IO::PathTraits::is_root
static yconstfn auto is_root(const _tString &str) ynothrow-> decltype(ystdex::string_length(str)==FetchRootNameLength(str))
Definition: YSLib/Service/FileSystem.h:118
CHRLib::CharSet::Encoding
Encoding
字符流编码标识。
Definition: Encoding.h:58
platform::containers::basic_string
std::basic_string< _tChar, _tTraits, _tAlloc > basic_string
满足 ISO C++03 std::basic_string 但不保证满足 ISO C++11 的实现。
Definition: Container.h:98
YSLib::Text::str
const char const char * str
Definition: TextFile.h:81
CHRLib::c
c
Definition: CharacterProcessing.h:81
yforward
#define yforward(_expr)
根据参数类型使用 std::forward 传递对应参数。
Definition: ydef.h:995
platform::IterateLink
YF_API bool IterateLink(string &, size_t &)
迭代访问链接：替换非空路径并按需减少允许链接计数。
Definition: YCLib/FileSystem.cpp:303
YSLib::IO::PreserveModificationAndAccessTime
const auto PreserveModificationAndAccessTime(ystdex::bind_forward(&FileDescriptor::SetModificationAndAccessTime,&FileDescriptor::GetModificationAndAccessTime))
保持修改和访问时间。
YSLib::IO::Path::Path
Path(_type &&arg)
Definition: YSLib/Service/FileSystem.h:245
CHRLib::char16_t
char16_t((*c_ptr<< CHAR_BIT)|c_ptr[1])) inline PDefH(char16_t
取 c_ptr 指向的小端序双字节字符。
platform::SystemOption
SystemOption
系统配置选项。
Definition: YCommon.h:282
YSLib::IO::Path
路径。
Definition: YSLib/Service/FileSystem.h:214
ystdex::cpp2011::begin
_type * begin(_type(&&array)[_vN])
Definition: range.hpp:46
ystdex::string_traits::value_type
remove_rcv_t< decltype(std::declval< string_type >()[0])> value_type
Definition: string.hpp:58
YSLib::IO::PathTraits
文件路径特征。
Definition: YSLib/Service/FileSystem.h:78
YSLib::IO::PathTraits::is_self
static yconstfn bool is_self(const _tString &str) ynothrow
Definition: YSLib/Service/FileSystem.h:133
ystdex::size
auto size(const _tRange &c) -> decltype(c.size())
类容器访问。
Definition: range.hpp:233
YSLib::IO::YB_NONNULL
YF_API YB_NONNULL(1) UniqueFile OpenFile(const char *
打开文件。
Definition: File.h:62
YSLib::IO::Path::DefDeCtor
DefDeCtor(Path) explicit Path(ypath pth) ynothrow
无参数构造：默认实现。
Definition: YSLib/Service/FileSystem.h:229
ystdex::dep_ops::dividable
_t< details::ops_seq< _type, _type2, _tOpt, details::ops_bin_id_seq< 3, 0, 1 >>> dividable
Definition: operators.hpp:280
YSLib::path
YF_API const char * path
Definition: Initialization.h:77
platform::mode_t
::mode_t mode_t
文件模式类型。
Definition: FileIO.h:114
platform::DefaultPMode
YF_API YB_STATELESS mode_t DefaultPMode() ynothrow
取默认权限。
Definition: FileIO.cpp:772
YSLib::IO::MakeNormalizedAbsolute
Path MakeNormalizedAbsolute(const Path &pth, size_t init_size)
Definition: YSLib/Service/FileSystem.cpp:60
YSLib::IO::Path::Path
Path(_type &&arg, Text::Encoding enc)
Definition: YSLib/Service/FileSystem.h:251
YSLib::IO::IsAbsolute
IsAbsolute
Definition: YSLib/Service/FileSystem.h:57
platform_ex::Windows::Directory
Definition: MinGW32.h:452
YSLib::swap
void swap(ValueNode &x, ValueNode &y) ynothrow
Definition: ValueNode.cpp:73
YSLib::Text::String
YSLib 标准字符串（使用 UCS-2 作为内部编码）。
Definition: YString.h:46