YSTest: FileSystem.h 源文件

YSTest PreAlpha_b700_20160611 The YSLib Test Project

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

- 文件列表
- 文件成员

YCLib/FileSystem.h
浏览该文件的文档.
1 /*
2 © 2011-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 YCL_INC_FileSystem_h_
29 #define YCL_INC_FileSystem_h_ 1
30
31 #include "YModules.h"
32 #include YFM_YCLib_Container // for std::is_integral, std::is_array,
33 // ystdex::remove_reference_t, size, ystdex::is_null, string, u16string,
34 // wstring, ystdex::to_array, std::uint8_t, std::uint32_t, pair, tuple;
35 #include YFM_YCLib_Reference // for unique_ptr, nptr;
36 #include <system_error> // for std::system_error;
37 #include <ystdex/base.h> // for ystdex::deref_self;
38 #include <ystdex/iterator.hpp> // for ystdex::indirect_input_iterator;
39 #include <ctime> // for std::time_t;
40 #include YFM_YCLib_Debug // for Nonnull, Deref;
41 #include <ystdex/cstdint.hpp> // for ystdex::read_uint_le;
42
43 #if !YCL_Win32
44 struct dirent;
46 #endif
47
48 namespace platform
49 {
50
55 #define YCL_FS_StringIsCurrent(_s, _p) \
56 (ystdex::string_length(_s) == 1 && _s[0] == _p('.'))
57
62 #define YCL_FS_StringIsParent(_s, _p) \
63 (ystdex::string_length(_s) == 2 && _s[0] == _p('.') && _s[1] == _p('.'))
64
71 #if YCL_Win32
72
76 # define YCL_PATH_DELIMITER '\\'
77 // #define YCL_PATH_DELIMITER L'\\'
82 # define YCL_PATH_SEPARATOR "\\"
83 // #define YCL_PATH_SEPARATOR L"\\"
88 # define YCL_PATH_ROOT YCL_PATH_SEPARATOR
89
90 # define YCL_FS_CharIsDelimiter(_c, _p) (_c == _p('/') || _c == _p('\\'))
91 #elif defined(YCL_API_POSIXFileSystem)
92
96 # define YCL_PATH_DELIMITER '/'
97
101 # define YCL_PATH_SEPARATOR "/"
102
105 # define YCL_PATH_ROOT YCL_PATH_SEPARATOR
106
107 # define YCL_FS_CharIsDelimiter(_c, _p) (_c == _p(YCL_PATH_DELIMITER))
108 #else
109 # error "Unsupported platform found."
110 #endif
111
113
114 static_assert(std::is_integral<decltype(YCL_PATH_DELIMITER)>(),
115 "Illegal type of delimiter found.");
116 static_assert(std::is_array<ystdex::remove_reference_t<decltype(
117 YCL_PATH_SEPARATOR)>>(), "Non-array type of separator found.");
118 static_assert(size(YCL_PATH_SEPARATOR) == 2,
119 "Wrong length of separator found.");
120 static_assert(YCL_PATH_SEPARATOR[0] == YCL_PATH_DELIMITER,
121 "Mismatched path delimiter and separator found.");
122 static_assert(ystdex::is_null(YCL_PATH_SEPARATOR[1]),
123 "Non-null-terminator as end of separator.");
125
126
128
129 template<typename _tChar>
130 yconstfn bool
131 IsColon(_tChar c) ynothrow
132 {
133 return c == _tChar(':');
134 }
135
136 template<typename _tChar>
137 yconstfn bool
138 IsSlash(_tChar c) ynothrow
139 {
140 return c == _tChar('/');
141 }
142
143 template<typename _tChar>
144 inline YB_NONNULL(1) const _tChar*
145 FindColon(const _tChar* p) ynothrowv
146 {
147 return ystdex::ntctschr(Nonnull(p), _tChar(':'));
148 }
149
165 template<typename _tChar>
166 inline YB_NONNULL(2) bool
167 IsAbsolute_P(IDTag<YF_Platform_DS>, const _tChar* path) ynothrowv
168 {
169 return IsSlash(Deref(path)) || platform::FindColon(path);
170 }
171 template<typename _tChar>
172 inline bool
173 IsAbsolute_P(IDTag<YF_Platform_DS>, basic_string_view<_tChar> path) ynothrowv
174 {
175 YAssertNonnull(path.data());
176 return !path.empty() && (IsSlash(path[0])
177 || path.find(_tChar(':')) != basic_string_view<_tChar>::npos);
178 }
179 template<typename _tChar>
180 inline YB_NONNULL(2) bool
181 IsAbsolute_P(IDTag<YF_Platform_Win32>, const _tChar* path) ynothrowv
182 {
183 return Deref(path) == YCL_PATH_DELIMITER
184 || (*path != _tChar() && IsColon(*++path));
185 }
186 template<typename _tChar>
187 inline bool
188 IsAbsolute_P(IDTag<YF_Platform_Win32>, basic_string_view<_tChar> path) ynothrowv
189 {
190 YAssertNonnull(path.data());
191 return path.length() > 1
192 && (path[0] == _tChar(YCL_PATH_DELIMITER) || IsColon(path[2]));
193 }
194 template<typename _tChar>
195 inline YB_NONNULL(2) bool
196 IsAbsolute_P(IDTagBase, const _tChar* path) ynothrowv
197 {
198 return IsSlash(Deref(path));
199 }
200 template<typename _tChar>
201 inline bool
202 IsAbsolute_P(IDTagBase, basic_string_view<_tChar> path) ynothrowv
203 {
204 YAssertNonnull(path.data());
205 return !path.empty() && IsSlash(path[0]);
206 }
207
209 YCL_DefPlatformFwdTmpl(IsAbsolute, IsAbsolute_P)
211
217 template<typename _tChar>
218 YB_NONNULL(2) size_t
219 FetchRootNameLength_P(IDTag<YF_Platform_DS>, const _tChar* path) ynothrowv
220 {
221 auto p(platform::FindColon(path));
222
223 if(!p)
224 p = path;
225 while(*p == '/')
226 ++p;
227 return size_t(p - path);
228 }
229 template<typename _tChar>
230 size_t
231 FetchRootNameLength_P(IDTag<YF_Platform_DS>, basic_string_view<_tChar> path)
232 ynothrowv
233 {
234 YAssertNonnull(path.data());
235
236 auto n(path.find_first_not_of(_tChar(':')));
237
238 if(n != basic_string_view<_tChar>::npos)
239 n = path.find_first_not_of(_tChar('/'), n);
240 return n != basic_string_view<_tChar>::npos ? n : path.length();
241 }
242 template<typename _tChar>
243 YB_NONNULL(2) size_t
244 FetchRootNameLength_P(IDTag<YF_Platform_Win32>, const _tChar* path) ynothrowv
245 {
246 if(Deref(path) != _tChar() && IsColon(path[1]))
247 {
248 size_t n = 2;
249
250 // TODO: Extract as %ystdex::tstr_find_first_not_of?
251 while(path[n] != _tChar()
252 && !YCL_FS_CharIsDelimiter(path[n], _tChar))
253 ++n;
254 return n;
255 }
256 return 0;
257 }
258 template<typename _tChar>
259 size_t
260 FetchRootNameLength_P(IDTag<YF_Platform_Win32>, basic_string_view<_tChar> path)
261 ynothrowv
262 {
263 YAssertNonnull(path.data());
264
265 const auto l(path.length());
266
267 if(l >= 2 && IsColon(path[1]))
268 {
269 // XXX: Use %YCL_FS_CharIsDelimiter?
270 const auto
271 n(path.find_first_not_of(&ystdex::to_array<_tChar>("/\\")[0], 2));
272
273 return n != basic_string_view<_tChar>::npos ? n : 2;
274 }
275 return 0;
276 }
278 template<typename _tChar>
279 inline YB_NONNULL(2) size_t
280 FetchRootNameLength_P(IDTagBase, const _tChar* path) ynothrowv
281 {
282 return Deref(path) == _tChar('/') ? 1 : 0;
283 }
284 template<typename _tChar>
285 inline size_t
286 FetchRootNameLength_P(IDTagBase, const basic_string_view<_tChar> path)
287 ynothrowv
288 {
289 YAssertNonnull(path.data());
290 return !path.empty() && path[0] == _tChar('/') ? 1 : 0;
291 }
292
294 YCL_DefPlatformFwdTmpl(FetchRootNameLength, FetchRootNameLength_P)
296
297
299
300 template<class _tString>
301 yconstfn bool
302 EndsWithNonSeperator_P(IDTag<YF_Platform_Win32>, const _tString& path) ynothrow
303 {
304 return !path.empty() && !IsSlash(path.back())
305 && path.back() != YCL_PATH_DELIMITER;
306 }
307 template<class _tString>
308 yconstfn bool
309 EndsWithNonSeperator_P(IDTagBase, const _tString& path) ynothrow
310 {
311 return !path.empty() && path.back() != YCL_PATH_DELIMITER;
312 }
313
314 YCL_DefPlatformFwdTmpl(EndsWithNonSeperator, EndsWithNonSeperator_P)
316
317
318
319 enum class NodeCategory : std::uint_least32_t;
321
322
331
333
335
341 #if YCL_DS
342 YB_NORETURN
343 #endif
344 YF_API YB_NONNULL(1, 2) void
345 CreateHardLink(const char*, const char*);
346 #if YCL_DS
347 YB_NORETURN
348 #endif
349 YF_API YB_NONNULL(1, 2) void
350 CreateHardLink(const char16_t*, const char16_t*);
352
361 #if YCL_DS
362 YB_NORETURN
363 #endif
364 YF_API YB_NONNULL(1, 2) void
365 CreateSymbolicLink(const char*, const char*, bool = {});
366 #if YCL_DS
367 YB_NORETURN
368 #endif
369 YF_API YB_NONNULL(1, 2) void
370 CreateSymbolicLink(const char16_t*, const char16_t*, bool = {});
372
373
382 #if YCL_DS
383 YB_NORETURN
384 #endif
385 YF_API YB_NONNULL(1) string
386 ReadLink(const char*);
387 #if YCL_DS
388 YB_NORETURN
389 #endif
390 YF_API YB_NONNULL(1) u16string
391 ReadLink(const char16_t*);
393
394
403 YF_API YB_NONNULL(1) string
404 ResolvePath(const char*, size_t = 1);
405 YF_API YB_NONNULL(1) u16string
406 ResolvePath(const char16_t*, size_t = 1);
408
409
410
416 class YF_API DirectorySession
417 {
418 public:
419 #if YCL_Win32
420 class Data;
422 #else
423 using Data = void;
425 #endif
426 using NativeHandle = Data*;
427
428 private:
430 class YF_API Deleter
431 {
432 public:
433 using pointer = NativeHandle;
434
436 void
437 operator()(pointer) const ynothrowv;
438 };
439
440 #if !YCL_Win32
441 protected:
448 string sDirPath;
449 #endif
450
451 private:
453 unique_ptr_from<Deleter> dir;
454
455 public:
469 DirectorySession();
471 explicit YB_NONNULL(2)
472 DirectorySession(const char*);
473 explicit YB_NONNULL(2)
474 DirectorySession(const char16_t*);
476 DefDeMoveCtor(DirectorySession)
482 DefDeDtor(DirectorySession)
483
485 DefDeMoveAssignment(DirectorySession)
486
488 DefGetter(const ynothrow, NativeHandle, NativeHandle, dir.get())
489
491 void
492 Rewind() ynothrow;
493 };
494
495
500 class YF_API HDirectory final
501 : private DirectorySession, private ystdex::deref_self<HDirectory>
502 {
504 friend deref_self<HDirectory>;
505
506 public:
508 using NativeChar =
509 #if YCL_Win32
510 char16_t
511 #else
512 char
513 #endif
514 ;
515
516 private:
517 #if YCL_Win32
518 using DirentData = wstring;
519 #else
520 using DirentData = ::dirent;
521 #endif
522
529 tidy_ptr<DirentData> p_dirent{};
530
531 public:
536 using DirectorySession::DirectorySession;
538 DefDeMoveCtor(HDirectory)
539
540
541 DefDeMoveAssignment(HDirectory)
542
548 using ystdex::deref_self<HDirectory>::operator*;
549
555 HDirectory&
556 operator++();
557
562 DefBoolNeg(explicit, bool(p_dirent))
563
565 DefCvt(const ynothrow, basic_string_view<NativeChar>, GetNativeName())
567 operator string() const;
569 operator u16string() const;
570
577 NodeCategory
578 GetNodeCategory() const ynothrow;
585 YB_ATTR_returns_nonnull const NativeChar*
586 GetNativeName() const ynothrow;
587
589 using DirectorySession::Rewind;
590 };
591
597 inline PDefH(bool, is_undereferenceable, const HDirectory& i) ynothrow
598 ImplRet(!i)
599
600
605 using FileIterator = ystdex::indirect_input_iterator<HDirectory*>;
606
607
612 enum class FileSystemType
613 {
614 Unknown,
615 FAT12,
616 FAT16,
617 FAT32
618 };
619
620
625 namespace FAT
626 {
627
628 using EntryDataUnit = std::uint8_t;
629 using ClusterIndex = std::uint32_t;
630
632
633
635 enum BPB : size_t
637 {
638 BS_jmpBoot = 0,
639 BS_OEMName = 3,
640 BPB_BytsPerSec = 11,
641 BPB_SecPerClus = 13,
642 BPB_RsvdSecCnt = 14,
643 BPB_NumFATs = 16,
644 BPB_RootEntCnt = 17,
645 BPB_TotSec16 = 19,
646 BPB_Media = 21,
647 BPB_FATSz16 = 22,
648 BPB_SecPerTrk = 24,
649 BPB_NumHeads = 26,
650 BPB_HiddSec = 28,
651 BPB_TotSec32 = 32
652 };
653
658 yconstexpr const size_t MinSectorSize(512), MaxSectorSize(4096);
660
662 inline namespace FAT16
663 {
664
669 enum BPB : size_t
670 {
671 BS_DrvNum = 36,
672 BS_Reserved1 = 37,
673 BS_BootSig = 38,
674 BS_VolID = 39,
675 BS_VolLab = 43,
676 BS_FilSysType = 54,
677 _reserved_zero_448 = 62,
678 Signature_word = 510,
679 _reserved_remained = 512
680 };
681
682 } // inline namespace FAT16;
683
685 inline namespace FAT32
686 {
687
692 enum BPB : size_t
693 {
694 BPB_FATSz32 = 36,
695 BPB_ExtFlags = 40,
696 BPB_FSVer = 42,
697 BPB_RootClus = 44,
698 BPB_FSInfo = 48,
699 BPB_BkBootSec = 50,
700 BPB_Reserved = 52,
701 BS_DrvNum = 64,
702 BS_Reserved1 = 65,
703 BS_BootSig = 66,
704 BS_VolID = 67,
705 BS_VolLab = 71,
706 BS_FilSysType = 82,
707 _reserved_zero_420 = 90
708 };
709
710 } // inline namespace FAT32;
711
717 using VolumeLabel = array<byte, 11>;
718
720
721 enum FSI : size_t
723 {
724 FSI_LeadSig = 0,
725 FSI_Reserved1 = 4,
726 FSI_StrucSig = 484,
727 FSI_Free_Count = 488,
728 FSI_Nxt_Free = 492,
729 FSI_Reserved2 = 496,
730 FSI_TrailSig = 508
731 };
732
733 yconstexpr const std::uint32_t FSI_LeadSig_Value(0x41615252),
734 FSI_StrucSig_Value(0x61417272), FSI_TrailSig_Value(0xAA550000);
736
737
742 enum class Attribute : EntryDataUnit
743 {
744 ReadOnly = 0x01,
745 Hidden = 0x02,
746 System = 0x04,
747 VolumeID = 0x08,
748 Directory = 0x10,
749 Archive = 0x20,
750 LongFileName = ReadOnly | Hidden | System | VolumeID
751 };
752
754 DefBitmaskEnum(Attribute)
755
756
757 namespace Clusters
759 {
760
761 // !\see Microsoft FAT Specification Section 3.2 。
763 yconstexpr const size_t PerFAT12(4085);
764 yconstexpr const size_t PerFAT16(65525);
766
767 enum : ClusterIndex
768 {
769 FAT16RootDirectory = 0,
775 MaxValid12 = 0xFF6,
776 MaxValid16 = 0xFFF6,
777 MaxValid32 = 0xFFFFFF6,
778 Bad12 = 0xFF7,
779 Bad16 = 0xFFF7,
780 Bad32 = 0xFFFFFF7,
781 EndOfFile12 = 0xFFF,
782 EndOfFile16 = 0xFFFF,
783 EndOfFile32 = 0xFFFFFFFF,
785 EndOfFile = 0x0FFFFFFF,
786 First = 0x00000002,
787 Root = 0x00000000,
788 Free = 0x00000000,
789 Error = 0xFFFFFFFF
790 };
791
793 inline PDefH(bool, IsFreeOrEOF, ClusterIndex c) ynothrow
794 ImplRet(c == Clusters::Free || c == Clusters::EndOfFile)
795
796 } // namespace Clusters;
797
798
800 const char IllegalAliasCharacters[]{"\\/:;*?\"<>|&+,=[] "};
801
802
804 using FileSize = std::uint32_t;
805
810 static yconstexpr const auto MaxFileSize(FileSize(0xFFFFFFFF));
811
812
814 using Timestamp = std::uint16_t;
815
817 YF_API std::time_t
818 ConvertFileTime(Timestamp, Timestamp) ynothrow;
819
821 YF_API pair<Timestamp, Timestamp>
822 FetchDateTime() ynothrow;
823
824
830 namespace LFN
831 {
832
834 enum Offsets
835 {
837 Ordinal = 0x00,
838 Char0 = 0x01,
839 Char1 = 0x03,
840 Char2 = 0x05,
841 Char3 = 0x07,
842 Char4 = 0x09,
844 Flag = 0x0B,
846 Reserved1 = 0x0C,
848 CheckSum = 0x0D,
849 Char5 = 0x0E,
850 Char6 = 0x10,
851 Char7 = 0x12,
852 Char8 = 0x14,
853 Char9 = 0x16,
854 Char10 = 0x18,
856 Reserved2 = 0x1A,
857 Char11 = 0x1C,
858 Char12 = 0x1E
859 };
860
862 yconstexpr const size_t OffsetTable[]{0x01, 0x03, 0x05, 0x07, 0x09, 0x0E,
863 0x10, 0x12, 0x14, 0x16, 0x18, 0x1C, 0x1E};
864
865 enum : size_t
866 {
868 MaxLength = 256,
870 MaxMBCSLength = MaxLength * 3,
871 EntryLength = size(OffsetTable),
872 AliasEntryLength = 11,
873 MaxAliasMainPartLength = 8,
874 MaxAliasExtensionLength = 3,
875 MaxAliasLength = MaxAliasMainPartLength + MaxAliasExtensionLength + 2,
876 MaxNumericTail = 999999
877 };
878
879 enum EntryValues : EntryDataUnit
880 {
882 CaseLowerBasename = 0x08,
884 CaseLowerExtension = 0x10,
886 LastLongEntry = 0x40
887 };
888
890 const char IllegalCharacters[]{"\\/:*?\"<>|"};
891
893
894
901 YF_API tuple<string, string, bool>
902 ConvertToAlias(const u16string&);
903
905 inline PDefH(size_t, FetchLongNameOffset, EntryDataUnit ord) ynothrow
906 ImplRet((size_t(ord & ~LastLongEntry) - 1U) * EntryLength)
908
913 YF_API string
914 ConvertToMBCS(const char16_t* path);
915
921 YF_API YB_NONNULL(1) EntryDataUnit
922 GenerateAliasChecksum(const EntryDataUnit*) ynothrowv;
923
929 YF_API bool
930 ValidateName(string_view) ynothrowv;
931
937 YF_API void
938 WriteNumericTail(string&, size_t) ynothrowv;
939
940 } // namespace LFN;
941
943
944 yconstexpr const size_t EntryDataSize(0x20);
946
951 class YF_API EntryData final : private array<EntryDataUnit, EntryDataSize>
952 {
953 public:
954 using Base = array<EntryDataUnit, EntryDataSize>;
959 enum Offsets : size_t
960 {
961 Name = 0x00,
962 Extension = 0x08,
963 Attributes = 0x0B,
965 CaseInfo = 0x0C,
966 CTimeTenth = 0x0D,
967 CTime = 0x0E,
968 CDate = 0x10,
969 ADate = 0x12,
970 ClusterHigh = 0x14,
971 MTime = 0x16,
972 MDate = 0x18,
973 Cluster = 0x1A,
974 FileSize = 0x1C
975 };
977 enum : EntryDataUnit
978 {
979 Last = 0x00,
980 Free = 0xE5,
981 };
982
983 using Base::operator[];
984 using Base::data;
985
986 DefPred(const ynothrow, Directory,
987 bool(Attribute((*this)[Attributes]) & Attribute::Directory))
988 DefPred(const ynothrow, LongFileName,
989 Attribute((*this)[Attributes]) == Attribute::LongFileName)
990 DefPred(const ynothrow, Volume, bool(Attribute((*this)[Attributes])
991 & Attribute::VolumeID))
992 DefPred(const ynothrow, Writable,
993 !bool(Attribute((*this)[Attributes]) & Attribute::ReadOnly))
994
995 PDefH(void, SetDirectoryAttribute, ) ynothrow
996 ImplExpr((*this)[Attributes] = EntryDataUnit(Attribute::Directory))
997 PDefH(void, SetDot, size_t n) ynothrowv
998 ImplExpr(YAssert(n < EntryDataSize, "Invalid argument found."),
999 (*this)[n] = '.')
1000
1001 PDefH(void, Clear, ) ynothrow
1002 ImplExpr(ystdex::trivially_fill_n(static_cast<Base*>(this)))
1003
1004 PDefH(void, ClearAlias, ) ynothrow
1005 ImplExpr(ystdex::trivially_fill_n(data(), LFN::AliasEntryLength, ' '))
1006
1011 void
1012 CopyLFN(char16_t*) const ynothrowv;
1013
1014 PDefH(void, FillLast, ) ynothrow
1015 ImplExpr(ystdex::trivially_fill_n(static_cast<Base*>(this), 1, Last))
1016
1027 pair<EntryDataUnit, size_t>
1028 FillNewName(string_view, std::function<bool(string_view)>);
1029
1034 bool
1035 FindAlias(string_view) const;
1036
1037 string
1038 GenerateAlias() const;
1039
1040 PDefH(std::uint32_t, ReadFileSize, ) ynothrow
1041 ImplRet(ystdex::read_uint_le<32>(data() + FileSize))
1042
1043 void
1044 SetupRoot(ClusterIndex) ynothrow;
1045
1046 void
1047 WriteAlias(const string&) ynothrow;
1048
1049 void
1050 WriteCDateTime() ynothrow;
1051
1052 void
1053 WriteCluster(ClusterIndex) ynothrow;
1054
1055 void
1056 WriteDateTime() ynothrow;
1057 };
1059
1060
1068 YF_API YB_NONNULL(1) YB_PURE const char*
1069 CheckColons(const char*);
1070
1071 } // namespace FAT;
1072
1073 } // namespace platform;
1074
1075 namespace platform_ex
1076 {
1077
1078 } // namespace platform_ex;
1079
1080 #endif
1081
platform::NodeCategory::Directory
platform::p
while p p
Definition: YCLib/FileSystem.h:225
ystdex::trivially_fill_n
_type * trivially_fill_n(_type *first, size_t n=1, byte value={})
填充字节序列。
Definition: algorithm.hpp:363
ystdex::is_null
bool is_null(_tChar c)
使用 std::char_traits::eq 判断是否为空字符。
Definition: cstring.h:127
YB_NORETURN
#define YB_NORETURN
指定无返回值函数。
Definition: ydef.h:478
platform::FAT::LFN::Char9
Definition: YCLib/FileSystem.h:853
platform::FAT::BPB_Media
Definition: YCLib/FileSystem.h:646
ystdex::string_view
basic_string_view< char > string_view
Definition: string_view.hpp:415
yconstexpr
#define yconstexpr
指定编译时常量表达式。
Definition: ydef.h:653
platform::FAT::FAT32::BPB_FATSz32
Definition: YCLib/FileSystem.h:694
platform::FAT::FAT32::BPB_FSInfo
Definition: YCLib/FileSystem.h:698
YF_Platform_DS
#define YF_Platform_DS
目标平台标识。
Definition: Platform.h:130
platform::containers::string
basic_string< char > string
Definition: Container.h:101
platform::Nonnull
_type && Nonnull(_type &&p) ynothrow
断言并返回非空指针。
Definition: Debug.h:411
platform::FAT::FSI_Reserved1
Definition: YCLib/FileSystem.h:725
YF_Platform_Win32
#define YF_Platform_Win32
Win32 平台。
Definition: Platform.h:136
platform::FAT::EntryDataSize
yconstexpr const size_t EntryDataSize(0x20)
目录项数据大小。
platform::DirectorySession::DirectorySession
DirectorySession()
构造：打开目录路径。
Definition: YCLib/FileSystem.cpp:361
platform::FAT::LFN::Char1
Definition: YCLib/FileSystem.h:839
platform::FAT::LFN::GenerateAliasChecksum
EntryDataUnit GenerateAliasChecksum(const EntryDataUnit *p) ynothrowv
Definition: YCLib/FileSystem.cpp:567
platform::DirectorySession::NativeHandle
Data * NativeHandle
Definition: YCLib/FileSystem.h:426
platform::FAT::BPB_RsvdSecCnt
Definition: YCLib/FileSystem.h:642
iterator.hpp
通用迭代器。
platform::FAT::LFN::Ordinal
长文件名序数。
Definition: YCLib/FileSystem.h:837
platform::FAT::BPB_TotSec16
Definition: YCLib/FileSystem.h:645
platform::FAT::FSI_Free_Count
Definition: YCLib/FileSystem.h:727
platform::FAT::CheckColons
const char * CheckColons(const char *path)
Definition: YCLib/FileSystem.cpp:839
platform::YCL_DefPlatformFwdTmpl
YCL_DefPlatformFwdTmpl(IsAbsolute, IsAbsolute_P) template< typename _tChar > YB_NONNULL(2) size_t FetchRootNameLength_P(IDTag< YF_Platform_DS >
取指定路径的文件系统根节点名称的长度。
DefBitmaskEnum
#define DefBitmaskEnum(_tEnum)
Definition: YBaseMacro.h:475
platform::containers::u16string
basic_string< char16_t > u16string
Definition: Container.h:103
platform::DefCvt
yconstfn DefCvt(const ynothrow, typename Trait::IntegerType, Integer) yconstfn DefGetter(const ynothrow
ystdex::ntctschr
_tChar * ntctschr(_tChar *s, remove_const_t< _tChar > c)
在简单 NTCTS 内查找字符。
Definition: cstring.h:393
platform::FAT::EntryData::Base
array< EntryDataUnit, EntryDataSize > Base
Definition: YCLib/FileSystem.h:954
platform::NodeCategory::Invalid
platform::FAT::FetchDateTime
YF_API pair< Timestamp, Timestamp > FetchDateTime() ynothrow
取以实时时钟的文件日期和时间。
Definition: YCLib/FileSystem.cpp:626
platform::FAT::LFN::CaseLowerExtension
WinNT 小写扩展名。
Definition: YCLib/FileSystem.h:884
platform::FAT::LFN::Char10
Definition: YCLib/FileSystem.h:854
platform::DirectorySession::Deleter
Definition: YCLib/FileSystem.h:430
platform::NodeCategory
NodeCategory
文件节点类别。
Definition: FileIO.h:117
platform::FAT::Attribute::LongFileName
platform::FAT::LFN::Char8
Definition: YCLib/FileSystem.h:852
platform::IsAbsolute_P
bool IsAbsolute_P(IDTag< YF_Platform_DS >, basic_string_view< _tChar > path) ynothrowv
Definition: YCLib/FileSystem.h:173
ystdex::cpp2014::remove_reference_t
typename remove_reference< _type >::type remove_reference_t
Definition: type_traits.hpp:304
platform::FAT::BS_OEMName
Definition: YCLib/FileSystem.h:639
platform::size_t
YF_API size_t
Definition: FileIO.h:1262
platform::FAT::BS_jmpBoot
Definition: YCLib/FileSystem.h:638
platform::FAT::LFN::OffsetTable
yconstexpr const size_t OffsetTable[]
组成长文件名中的 UCS-2 字符在项中的偏移量表。
Definition: YCLib/FileSystem.h:862
platform::FAT::FAT32::_reserved_zero_420
Definition: YCLib/FileSystem.h:707
YAssert
#define YAssert(_expr, _msg)
Definition: cassert.h:105
platform::FAT::LFN::IllegalCharacters
const char IllegalCharacters[]
非法长文件名字符。
Definition: YCLib/FileSystem.h:890
platform::FAT::MinSectorSize
yconstexpr const size_t MinSectorSize(512)
BIOS 参数块偏移量域 BPB_BytsPerSec 的最值。
platform::FAT::BPB_NumHeads
Definition: YCLib/FileSystem.h:649
platform::FAT::FSI_TrailSig
Definition: YCLib/FileSystem.h:730
ystdex::data
auto data(_tRange &c) -> decltype(c.data())
Definition: range.hpp:280
platform::FAT::FSI_Nxt_Free
Definition: YCLib/FileSystem.h:728
platform::FAT::Attribute
Attribute
文件属性。
Definition: YCLib/FileSystem.h:742
platform::FAT::FSI_LeadSig_Value
yconstexpr const std::uint32_t FSI_LeadSig_Value(0x41615252)
platform::FAT::ConvertFileTime
YF_API std::time_t ConvertFileTime(Timestamp, Timestamp) ynothrow
转换日期和时间的时间戳为标准库时间类型。
Definition: YCLib/FileSystem.cpp:609
platform::FAT::FAT32::BPB_RootClus
Definition: YCLib/FileSystem.h:697
platform::FAT::FAT32::BS_FilSysType
Definition: YCLib/FileSystem.h:706
platform::FAT::LFN::MaxAliasExtensionLength
Definition: YCLib/FileSystem.h:874
CHRLib::c
c
Definition: CharacterProcessing.h:81
platform::FAT::LFN::Char0
Definition: YCLib/FileSystem.h:838
platform::FAT::FAT32::BS_Reserved1
Definition: YCLib/FileSystem.h:702
platform::FAT::LFN::Char12
Definition: YCLib/FileSystem.h:858
platform::NodeCategory::Unknown
platform::FAT::LFN::MaxNumericTail
Definition: YCLib/FileSystem.h:876
platform::FAT::BPB_FATSz16
Definition: YCLib/FileSystem.h:647
platform::FAT::LFN::LastLongEntry
Ordinal 中标记结束的项。
Definition: YCLib/FileSystem.h:886
platform::FAT::LFN::Char4
Definition: YCLib/FileSystem.h:842
platform::FAT::FAT32::BPB_BkBootSec
Definition: YCLib/FileSystem.h:699
platform::FAT::BPB_HiddSec
Definition: YCLib/FileSystem.h:650
CHRLib::char16_t
char16_t((*c_ptr<< CHAR_BIT)|c_ptr[1])) inline PDefH(char16_t
取 c_ptr 指向的小端序双字节字符。
YB_PURE
#define YB_PURE
指示函数或函数模板实例为纯函数。
Definition: ydef.h:501
platform::FAT::LFN::Flag
Definition: YCLib/FileSystem.h:844
platform::HDirectory::NativeChar
char NativeChar
Definition: YCLib/FileSystem.h:514
platform::FAT::LFN::Reserved2
Definition: YCLib/FileSystem.h:856
platform::FAT::FAT16::BPB
BPB
FAT12 和 FAT16 扩展 BIOS 参数块偏移量。
Definition: YCLib/FileSystem.h:669
platform::FAT::BPB_SecPerClus
Definition: YCLib/FileSystem.h:641
platform::FAT::LFN::ValidateName
YF_API bool ValidateName(string_view) ynothrowv
检查名称是否为合法的可被 UCS-2 表示的非控制字符组成。
Definition: YCLib/FileSystem.cpp:581
platform::FAT::LFN::Reserved1
Definition: YCLib/FileSystem.h:846
platform::FAT::LFN::Offsets
Offsets
长文件名目录项偏移量。
Definition: YCLib/FileSystem.h:834
platform
默认平台命名空间。
Definition: Container.h:47
platform::FAT::LFN::ConvertToAlias
YF_API tuple< string, string, bool > ConvertToAlias(const u16string &)
转换长文件名为别名。
Definition: YCLib/FileSystem.cpp:500
base.h
基类实用设施。
std
Definition: memory.hpp:1100
platform::Deref
yconstfn auto Deref(_type &&p) -> decltype(*p)
断言并解引用非空指针。
Definition: Debug.h:440
platform::FAT::FAT32::BS_VolID
Definition: YCLib/FileSystem.h:704
YAssertNonnull
#define YAssertNonnull(_expr)
Definition: cassert.h:114
platform::CreateSymbolicLink
void CreateSymbolicLink(const char *dst, const char *src, bool is_dir)
Definition: YCLib/FileSystem.cpp:240
platform::FAT::FAT32::BS_BootSig
Definition: YCLib/FileSystem.h:703
platform::ynothrow
const _tString &path ynothrow
Definition: YCLib/FileSystem.h:303
platform::FAT::FSI
FSI
文件系统信息块偏移量。
Definition: YCLib/FileSystem.h:722
platform::FAT::LFN::Char7
Definition: YCLib/FileSystem.h:851
platform::ReadLink
string ReadLink(const char *path)
Definition: YCLib/FileSystem.cpp:271
platform::FAT::LFN::MaxLength
UCS-2 项最大长度。
Definition: YCLib/FileSystem.h:868
platform::IDTag
平台标识的整数标记类型。
Definition: YCommon.h:71
platform::FAT::LFN::WriteNumericTail
YF_API void WriteNumericTail(string &, size_t) ynothrowv
在指定字符串写前缀字符 '~' 和整数的后缀以作为短文件名。
Definition: YCLib/FileSystem.cpp:591
DefDeMoveAssignment
#define DefDeMoveAssignment(_t)
Definition: YBaseMacro.h:190
ystdex::size
auto size(const _tRange &c) -> decltype(c.size())
类容器访问。
Definition: range.hpp:233
platform::DirectorySession::dir
unique_ptr_from< Deleter > dir
Definition: YCLib/FileSystem.h:453
platform::containers::wstring
basic_string< wchar_t > wstring
Definition: Container.h:108
platform::FAT::LFN::ConvertToMBCS
string ConvertToMBCS(const char16_t *path)
Definition: YCLib/FileSystem.cpp:559
platform_ex
平台扩展命名空间。
Definition: Android.h:45
YSLib::path
YF_API const char * path
Definition: Initialization.h:74
platform::FAT::LFN::CaseLowerBasename
WinNT 小写文件名。
Definition: YCLib/FileSystem.h:882
platform::FAT::FileSize
std::uint32_t FileSize
文件大小：字节数。
Definition: YCLib/FileSystem.h:804
platform::FileSystemType::FAT32
platform::DirectorySession::Data
void Data
Definition: YCLib/FileSystem.h:424
platform::DirectorySession
目录会话：表示打开的目录。
Definition: YCLib/FileSystem.h:416
ystdex
特性测试宏。
Definition: ydef.h:796
platform::FAT::LFN::Char3
Definition: YCLib/FileSystem.h:841
DefDeMoveCtor
#define DefDeMoveCtor(_t)
Definition: YBaseMacro.h:166
platform::FAT::LFN::Char6
Definition: YCLib/FileSystem.h:850
platform::FAT::EntryData
目录项数据。
Definition: YCLib/FileSystem.h:951
platform::FAT::BPB_BytsPerSec
Definition: YCLib/FileSystem.h:640
platform::FAT::FSI_LeadSig
Definition: YCLib/FileSystem.h:724
platform::FAT::LFN::CheckSum
短文件名（别名）校验和。
Definition: YCLib/FileSystem.h:848
platform::FAT::FAT32::BPB_ExtFlags
Definition: YCLib/FileSystem.h:695
platform::FAT::FAT16::_reserved_remained
Definition: YCLib/FileSystem.h:679
platform::FAT::FSI_StrucSig_Value
yconstexpr const std::uint32_t FSI_StrucSig_Value(0x61417272)
platform::FAT::FAT32::BPB_Reserved
Definition: YCLib/FileSystem.h:700
ystdex::is_undereferenceable
bool is_undereferenceable(const _tIter &)
Definition: deref_op.hpp:45
platform::FAT::FAT16::Signature_word
Definition: YCLib/FileSystem.h:678
YModules.h
ystdex::read_uint_le
make_width_int< _vWidth >::unsigned_type read_uint_le(const byte *buf)
从字节缓冲区读取指定宽的小端序无符号整数。
Definition: cstdint.hpp:315
YSLib::i
return i
Definition: YCoreUtilities.h:176
cstdint.hpp
ISO C 标准整数类型和相关扩展操作。
platform::IsColon
yconstfn bool IsColon(_tChar c) ynothrow
Definition: YCLib/FileSystem.h:131
platform::CreateHardLink
void CreateHardLink(const char *dst, const char *src)
Definition: YCLib/FileSystem.cpp:208
platform::FAT::BPB_TotSec32
Definition: YCLib/FileSystem.h:651
platform::ImplRet
const string &s ImplRet(s) YF_API string MakePathString(const char16_t *)
platform::FAT::LFN::MaxMBCSLength
UTF-8 项最大长度。
Definition: YCLib/FileSystem.h:870
platform::FAT::FAT32::BPB_FSVer
Definition: YCLib/FileSystem.h:696
platform::FetchRootNameLength_P
size_t FetchRootNameLength_P(IDTag< YF_Platform_DS >, basic_string_view< _tChar > path) ynothrowv
Definition: YCLib/FileSystem.h:231
platform::DirectorySession::Deleter::pointer
NativeHandle pointer
Definition: YCLib/FileSystem.h:433
platform::FileSystemType::FAT12
DefDeDtor
#define DefDeDtor(_t)
Definition: YBaseMacro.h:176
yconstfn
#define yconstfn
指定编译时常量函数。
Definition: ydef.h:654
platform::FAT::LFN::MaxAliasMainPartLength
Definition: YCLib/FileSystem.h:873
platform::FAT::EntryData::Offsets
Offsets
目录项偏移量。
Definition: YCLib/FileSystem.h:959
platform::FileSystemType
FileSystemType
已知文件系统类型。
Definition: YCLib/FileSystem.h:612
platform::FAT::LFN::MaxAliasLength
Definition: YCLib/FileSystem.h:875
platform::FAT::FSI_StrucSig
Definition: YCLib/FileSystem.h:726
platform::FAT::FAT32::BS_DrvNum
Definition: YCLib/FileSystem.h:701
platform::FAT::LFN::AliasEntryLength
Definition: YCLib/FileSystem.h:872
platform::FAT::FAT16::_reserved_zero_448
Definition: YCLib/FileSystem.h:677
platform::YB_NONNULL
YF_API YB_NONNULL(1) int uaccess(const char *path
测试路径可访问性。
Definition: YCLib/FileSystem.h:144
platform::FAT::ClusterIndex
std::uint32_t ClusterIndex
Definition: YCLib/FileSystem.h:629
platform::FAT::LFN::EntryValues
EntryValues
Definition: YCLib/FileSystem.h:879
platform::IsSlash
yconstfn bool IsSlash(_tChar c) ynothrow
Definition: YCLib/FileSystem.h:138
DefBoolNeg
#define DefBoolNeg(_spec,...)
定义表示显式转换 bool 操作符及其否定的 operator! 。
Definition: YBaseMacro.h:227
platform::ynothrowv
YF_API int amode ynothrowv
Definition: FileIO.h:491
platform::FAT::IllegalAliasCharacters
const char IllegalAliasCharacters[]
非法别名字符。
Definition: YCLib/FileSystem.h:800
platform::FAT::FSI_Reserved2
Definition: YCLib/FileSystem.h:729
YF_API
#define YF_API
Definition: Platform.h:56
YB_ATTR_returns_nonnull
#define YB_ATTR_returns_nonnull
指示返回非空属性。
Definition: ydef.h:390
platform::FileSystemType::FAT16
platform::FAT::VolumeLabel
array< byte, 11 > VolumeLabel
卷标数据类型。
Definition: YCLib/FileSystem.h:717
platform::FAT::LFN::Char5
Definition: YCLib/FileSystem.h:849
platform::DirectorySession::sDirPath
string sDirPath
目录路径。
Definition: YCLib/FileSystem.h:448
platform::HDirectory::DirentData
::dirent DirentData
Definition: YCLib/FileSystem.h:520
platform::FAT::LFN::Char11
Definition: YCLib/FileSystem.h:857
platform::FAT::Timestamp
std::uint16_t Timestamp
时间戳：表示日期和时间的整数类型。
Definition: YCLib/FileSystem.h:814
DefPred
#define DefPred(_q, _n,...)
Definition: YBaseMacro.h:231
platform::FAT::BPB
BPB
BIOS 参数块偏移量。
Definition: YCLib/FileSystem.h:636
platform::FAT::BPB_RootEntCnt
Definition: YCLib/FileSystem.h:644
platform::FAT::LFN::EntryLength
Definition: YCLib/FileSystem.h:871
platform::FAT::EntryDataUnit
std::uint8_t EntryDataUnit
Definition: YCLib/FileSystem.h:628
platform::FAT::MaxFileSize
static yconstexpr const auto MaxFileSize(FileSize(0xFFFFFFFF))
最大文件大小。
platform::FAT::BPB_NumFATs
Definition: YCLib/FileSystem.h:643
platform::FAT::BPB_SecPerTrk
Definition: YCLib/FileSystem.h:648
platform::HDirectory
目录句柄：表示打开的目录和内容迭代状态。
Definition: YCLib/FileSystem.h:500
platform::FAT::FSI_TrailSig_Value
yconstexpr const std::uint32_t FSI_TrailSig_Value(0xAA550000)
platform::IDTag< YF_Platform_Win32 >
Definition: YCommon.h:89
platform::DefGetter
yconstfn Integer &MaskTrait::AMask MaskTrait::XYZMaskN yconstfn DefGetter(const ynothrow, typename Trait::BType, B, Integer &MaskTrait::XMask) yconstfn DefGetter(const ynothrow
platform::bool
std::FILE *fp bool
Definition: FileIO.h:1187
platform::FAT::FAT32::BS_VolLab
Definition: YCLib/FileSystem.h:705
platform::FAT::FAT32::BPB
BPB
FAT32 扩展 BIOS 参数块偏移量。
Definition: YCLib/FileSystem.h:692
platform::PDefH
PDefH(string, MakePathString, const char *s) ImplRet(Nonnull(s)) inline PDefH(const string &
构造适合表示路径的字符串。
platform::FAT::MaxSectorSize
yconstexpr const size_t MaxSectorSize(4096)
platform::n
size_t n
Definition: YCLib/FileSystem.cpp:321
platform::EndsWithNonSeperator_P
yconstfn bool EndsWithNonSeperator_P(IDTagBase, const _tString &path) ynothrow
Definition: YCLib/FileSystem.h:309
YSLib::IO::IsAbsolute
IsAbsolute
Definition: YSLib/Service/FileSystem.h:351
platform::FAT::LFN::Char2
Definition: YCLib/FileSystem.h:840