YSTest: FileSystem.h 源文件

YSTest PreAlpha_b800_20170810 The YSLib Test Project

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

- 文件列表
- 文件成员

YCLib/FileSystem.h
浏览该文件的文档.
1 /*
2 © 2011-2017 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 ystdex::to_array, ystdex::string_traits,
33 // ystdex::decay_t, ystdex::rtrim, string, u16string, std::uint8_t,
34 // std::uint32_t, size, pair, tuple;
35 #include YFM_YCLib_Reference // for unique_ptr_from, tidy_ptr;
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 && !YCL_API_POSIXFileSystem
44 # error "Unsupported platform found."
45 #endif
46
47 #if !YCL_Win32
48 struct dirent;
50 #endif
51
52 namespace platform
53 {
54
56
57 template<typename _tChar>
58 yconstfn bool
59 IsColon(_tChar c) ynothrow
60 {
61 return c == _tChar(':');
62 }
63
64 template<typename _tChar>
65 inline YB_NONNULL(1) const _tChar*
66 FindColon(const _tChar* p) ynothrowv
67 {
68 return ystdex::ntctschr(Nonnull(p), _tChar(':'));
69 }
70
72
73
75 template<typename _tChar>
76 YCL_Tag_constfn YB_STATELESS _tChar
77 FetchSeparator_P(IDTag<YF_Platform_Win32>) ynothrow
78 {
79 return '\\';
80 }
81 template<typename _tChar>
82 YCL_Tag_constfn YB_STATELESS _tChar
83 FetchSeparator_P(IDTagBase) ynothrow
84 {
85 return '/';
86 }
87
88 template<typename _tChar>
89 yconstfn YB_STATELESS _tChar
90 FetchSeparator() ynothrow
91 {
92 return FetchSeparator_P<_tChar>(IDTag<YF_Platform>());
93 }
95
97
98 template<typename _tChar>
99 YCL_Tag_constfn YB_STATELESS bool
100 IsSeparator_P(IDTag<YF_Platform_Win32> tag, _tChar c) ynothrow
101 {
102 return c == FetchSeparator_P<_tChar>(tag) || c == _tChar('/');
103 }
104 template<typename _tChar>
105 YCL_Tag_constfn YB_STATELESS bool
106 IsSeparator_P(IDTagBase tag, _tChar c) ynothrow
107 {
108 return c == FetchSeparator_P<_tChar>(tag);
109 }
110
111 YCL_DefPlatformFwdTmpl(IsSeparator, IsSeparator_P)
113
114
131 template<typename _tChar>
132 inline YB_NONNULL(2) bool
133 IsAbsolute_P(IDTag<YF_Platform_DS> tag, const _tChar* path) ynothrowv
134 {
135 // XXX: Separator used in root.
136 return
137 platform::IsSeparator_P(tag, Deref(path)) || platform::FindColon(path);
138 }
139 template<typename _tChar>
140 inline bool
141 IsAbsolute_P(IDTag<YF_Platform_DS> tag, basic_string_view<_tChar> path)
142 ynothrowv
143 {
144 // XXX: Separator used in root.
145 YAssertNonnull(path.data());
146 return !path.empty() && (platform::IsSeparator_P(tag, path.front())
147 || path.find(_tChar(':')) != basic_string_view<_tChar>::npos);
148 }
149 template<typename _tChar>
150 inline YB_NONNULL(2) bool
151 IsAbsolute_P(IDTag<YF_Platform_Win32> tag, const _tChar* path) ynothrowv
152 {
153 return platform::IsSeparator_P(tag, Deref(path))
154 || (*path != _tChar() && IsColon(*++path));
155 }
156 template<typename _tChar>
157 inline bool
158 IsAbsolute_P(IDTag<YF_Platform_Win32> tag, basic_string_view<_tChar> path)
159 ynothrowv
160 {
161 YAssertNonnull(path.data());
162 return path.length() > 1
163 && (platform::IsSeparator_P(tag, path.front()) || IsColon(path[1]));
164 }
165 template<typename _tChar>
166 inline YB_NONNULL(2) bool
167 IsAbsolute_P(IDTagBase tag, const _tChar* path) ynothrowv
168 {
169 return platform::IsSeparator_P(tag, Deref(path));
170 }
171 template<typename _tChar>
172 inline bool
173 IsAbsolute_P(IDTagBase tag, basic_string_view<_tChar> path) ynothrowv
174 {
175 YAssertNonnull(path.data());
176 return !path.empty() && platform::IsSeparator_P(tag, path.front());
177 }
178
180 YCL_DefPlatformFwdTmpl(IsAbsolute, IsAbsolute_P)
182
188 template<typename _tChar>
189 YB_NONNULL(2) size_t
190 FetchRootNameLength_P(IDTag<YF_Platform_DS> tag, const _tChar* path) ynothrowv
191 {
192 auto p(platform::FindColon(path));
193
194 if(!p)
195 p = path;
196 while(platform::IsSeparator_P(tag, *p))
197 ++p;
198 return size_t(p - path);
199 }
200 template<typename _tChar>
201 size_t
202 FetchRootNameLength_P(IDTag<YF_Platform_DS>, basic_string_view<_tChar> path)
203 ynothrowv
204 {
205 YAssertNonnull(path.data());
206
207 auto n(path.find_first_not_of(_tChar(':')));
208
209 if(n != basic_string_view<_tChar>::npos)
210 n = path.find_first_not_of(_tChar('/'), n);
211 return n != basic_string_view<_tChar>::npos ? n : path.length();
212 }
213 template<typename _tChar>
214 YB_NONNULL(2) size_t
215 FetchRootNameLength_P(IDTag<YF_Platform_Win32> tag, const _tChar* path)
216 ynothrowv
217 {
218 if(Deref(path) != _tChar() && IsColon(path[1]))
219 {
220 size_t n = 2;
221
222 // TODO: Extract as %ystdex::tstr_find_first_not_of?
223 while(path[n] != _tChar() && !platform::IsSeparator_P(tag, path[n]))
224 ++n;
225 return n;
226 }
227 return 0;
228 }
229 template<typename _tChar>
230 size_t
231 FetchRootNameLength_P(IDTag<YF_Platform_Win32>, basic_string_view<_tChar> path)
232 ynothrowv
233 {
234 YAssertNonnull(path.data());
235 if(path.length() > 1 && IsColon(path[1]))
236 {
237 // XXX: Use %platform::IsSeparator_P?
238 const auto
239 n(path.find_first_not_of(&ystdex::to_array<_tChar>("/\\")[0], 2));
240
241 return n != basic_string_view<_tChar>::npos ? n : 2;
242 }
243 return 0;
244 }
246 template<typename _tChar>
247 inline YB_NONNULL(2) size_t
248 FetchRootNameLength_P(IDTagBase tag, const _tChar* path) ynothrowv
249 {
250 return platform::IsSeparator_P(tag, Deref(path)) ? 1 : 0;
251 }
252 template<typename _tChar>
253 inline size_t
254 FetchRootNameLength_P(IDTagBase tag, basic_string_view<_tChar> path)
255 ynothrowv
256 {
257 YAssertNonnull(path.data());
258 return !path.empty() && platform::IsSeparator_P(tag, path.front()) ? 1 : 0;
259 }
260
262 YCL_DefPlatformFwdTmpl(FetchRootNameLength, FetchRootNameLength_P)
264
265
271 template<class _tString>
272 yconstfn bool
273 EndsWithNonSeperator_P(IDTagBase tag, const _tString& path) ynothrow
274 {
275 return !path.empty() && !platform::IsSeparator_P(tag, path.back());
276 }
277
278 YCL_DefPlatformFwdTmpl(EndsWithNonSeperator, EndsWithNonSeperator_P)
280
282
283 template<class _tString>
284 YCL_Tag_constfn _tString&&
285 TrimTrailingSeperator_P(IDTag<YF_Platform_Win32>, _tString&& path, typename
286 ystdex::string_traits<_tString>::const_pointer tail = &ystdex::to_array<
287 typename ystdex::string_traits<_tString>::value_type>("/\\")[0]) ynothrow
288 {
289 return ystdex::rtrim(yforward(path), tail);
290 }
291
292 template<class _tString>
293 YCL_Tag_constfn _tString&&
294 TrimTrailingSeperator_P(IDTagBase, _tString&& path, typename
295 ystdex::string_traits<_tString>::const_pointer tail = &ystdex::to_array<
296 typename ystdex::string_traits<_tString>::value_type>("/")[0]) ynothrow
297 {
298 return ystdex::rtrim(yforward(path), tail);
299 }
300
301 YCL_DefPlatformFwdTmpl(TrimTrailingSeperator, TrimTrailingSeperator_P)
303
304
305
306
310 enum class NodeCategory : std::uint_least32_t
311 {
312 Empty = 0,
314
315 Invalid = 1 << 0,
316 Regular = 1 << 1,
318 Unknown = Invalid | Regular,
320
321 Device = 1 << 9,
322 Block = Device,
323 Character = Device | 1 << 7,
324 Communicator = 2 << 9,
325 FIFO = Communicator | 1 << 6,
326 Socket = Communicator | 2 << 6,
328 SymbolicLink = 1 << 12,
329 MountPoint = 2 << 12,
330 Junction = MountPoint,
332
333 Link = SymbolicLink | Junction,
335 Directory = 1 << 15,
337
338 Missing = 1 << 16,
339 Special = Link | Missing
341 };
342
347 DefBitmaskEnum(NodeCategory)
348
349
350
356 YF_API YB_NONNULL(1) bool
357 IsDirectory(const char*);
358 YF_API YB_NONNULL(1) bool
359 IsDirectory(const char16_t*);
361
362
371
373
375
381 #if YCL_DS
382 YB_NORETURN
383 #endif
384 YF_API YB_NONNULL(1, 2) void
385 CreateHardLink(const char*, const char*);
386 #if YCL_DS
387 YB_NORETURN
388 #endif
389 YF_API YB_NONNULL(1, 2) void
390 CreateHardLink(const char16_t*, const char16_t*);
392
401 #if YCL_DS
402 YB_NORETURN
403 #endif
404 YF_API YB_NONNULL(1, 2) void
405 CreateSymbolicLink(const char*, const char*, bool = {});
406 #if YCL_DS
407 YB_NORETURN
408 #endif
409 YF_API YB_NONNULL(1, 2) void
410 CreateSymbolicLink(const char16_t*, const char16_t*, bool = {});
412
413
424 #if YCL_DS
425 YB_NORETURN
426 #endif
427 YF_API YB_NONNULL(1) string
428 ReadLink(const char*);
429 #if YCL_DS
430 YB_NORETURN
431 #endif
432 YF_API YB_NONNULL(1) u16string
433 ReadLink(const char16_t*);
435
436
447 #if YCL_DS
448 inline PDefH(bool, IterateLink, string&, size_t&)
449 ImplRet({})
450 inline PDefH(bool, IterateLink, u16string&, size_t&)
451 ImplRet({})
452 #else
453 YF_API bool
454 IterateLink(string&, size_t&);
455 YF_API bool
456 IterateLink(u16string&, size_t&);
457 #endif
458
459
460
461
468 class YF_API DirectorySession
469 {
470 public:
471 #if YCL_Win32
472 class Data;
474 #else
475 using Data = void;
477 #endif
478 using NativeHandle = Data*;
479
480 private:
482 class YF_API Deleter
483 #if YCL_Win32
484 : private default_delete<Data>
485 #endif
486 {
487 public:
488 using pointer = NativeHandle;
489
491 void
492 operator()(pointer) const ynothrowv;
493 };
494
495 #if !YCL_Win32
496 protected:
503 string sDirPath;
504 #endif
505
506 private:
508 unique_ptr_from<Deleter> dir;
509
510 public:
524 DirectorySession();
526 explicit YB_NONNULL(2)
527 DirectorySession(const char*);
528 explicit YB_NONNULL(2)
529 DirectorySession(const char16_t*);
531
535 DefDeMoveCtor(DirectorySession)
540 DefDeDtor(DirectorySession)
541
546 DefDeMoveAssignment(DirectorySession)
547
549 DefGetter(const ynothrow, NativeHandle, NativeHandle, dir.get())
550
552 void
553 Rewind() ynothrow;
554 };
555
556
562 class YF_API HDirectory final
563 : private DirectorySession, private ystdex::deref_self<HDirectory>
564 {
566 friend deref_self<HDirectory>;
567
568 public:
570 using NativeChar =
571 #if YCL_Win32
572 char16_t
573 #else
574 char
575 #endif
576 ;
578 using iterator = ystdex::indirect_input_iterator<HDirectory*>;
579
580 private:
581 #if YCL_Win32
582 u16string dirent_str;
584 #else
585
589 tidy_ptr<::dirent> p_dirent{};
590 #endif
591
592 public:
597 using DirectorySession::DirectorySession;
599 DefDeMoveCtor(HDirectory)
600
601
602 DefDeMoveAssignment(HDirectory)
603
609 using ystdex::deref_self<HDirectory>::operator*;
610
615 HDirectory&
616 operator++();
617
622 #if YCL_Win32
623 DefBoolNeg(explicit, !dirent_str.empty())
624 #else
625 DefBoolNeg(explicit, bool(p_dirent))
626 #endif
627
629 DefCvt(const ynothrow, basic_string_view<NativeChar>, GetNativeName())
631 operator string() const;
633 operator u16string() const;
634
641 NodeCategory
642 GetNodeCategory() const ynothrow;
649 YB_ATTR_returns_nonnull const NativeChar*
650 GetNativeName() const ynothrow;
651
653 using DirectorySession::Rewind;
654
656
657 PDefH(iterator, begin, )
658 ImplRet(this)
659
660 PDefH(iterator, end, )
661 ImplRet(iterator())
663 };
664
670 inline PDefH(bool, is_undereferenceable, const HDirectory& i) ynothrow
671 ImplRet(!i)
672
673
678 enum class FileSystemType
679 {
680 Unknown,
681 FAT12,
682 FAT16,
683 FAT32
684 };
685
686
691 namespace FAT
692 {
693
694 using EntryDataUnit = std::uint8_t;
695 using ClusterIndex = std::uint32_t;
696
698
699
701 enum BPB : size_t
703 {
704 BS_jmpBoot = 0,
705 BS_OEMName = 3,
706 BPB_BytsPerSec = 11,
707 BPB_SecPerClus = 13,
708 BPB_RsvdSecCnt = 14,
709 BPB_NumFATs = 16,
710 BPB_RootEntCnt = 17,
711 BPB_TotSec16 = 19,
712 BPB_Media = 21,
713 BPB_FATSz16 = 22,
714 BPB_SecPerTrk = 24,
715 BPB_NumHeads = 26,
716 BPB_HiddSec = 28,
717 BPB_TotSec32 = 32
718 };
719
724 yconstexpr const size_t MinSectorSize(512), MaxSectorSize(4096);
726
728 inline namespace FAT16
729 {
730
735 enum BPB : size_t
736 {
737 BS_DrvNum = 36,
738 BS_Reserved1 = 37,
739 BS_BootSig = 38,
740 BS_VolID = 39,
741 BS_VolLab = 43,
742 BS_FilSysType = 54,
743 _reserved_zero_448 = 62,
744 Signature_word = 510,
745 _reserved_remained = 512
746 };
747
748 } // inline namespace FAT16;
749
751 inline namespace FAT32
752 {
753
758 enum BPB : size_t
759 {
760 BPB_FATSz32 = 36,
761 BPB_ExtFlags = 40,
762 BPB_FSVer = 42,
763 BPB_RootClus = 44,
764 BPB_FSInfo = 48,
765 BPB_BkBootSec = 50,
766 BPB_Reserved = 52,
767 BS_DrvNum = 64,
768 BS_Reserved1 = 65,
769 BS_BootSig = 66,
770 BS_VolID = 67,
771 BS_VolLab = 71,
772 BS_FilSysType = 82,
773 _reserved_zero_420 = 90
774 };
775
776 } // inline namespace FAT32;
777
783 using VolumeLabel = array<byte, 11>;
784
786
787 enum FSI : size_t
789 {
790 FSI_LeadSig = 0,
791 FSI_Reserved1 = 4,
792 FSI_StrucSig = 484,
793 FSI_Free_Count = 488,
794 FSI_Nxt_Free = 492,
795 FSI_Reserved2 = 496,
796 FSI_TrailSig = 508
797 };
798
799 yconstexpr const std::uint32_t FSI_LeadSig_Value(0x41615252),
800 FSI_StrucSig_Value(0x61417272), FSI_TrailSig_Value(0xAA550000);
802
803
808 enum class Attribute : EntryDataUnit
809 {
810 ReadOnly = 0x01,
811 Hidden = 0x02,
812 System = 0x04,
813 VolumeID = 0x08,
814 Directory = 0x10,
815 Archive = 0x20,
816 LongFileName = ReadOnly | Hidden | System | VolumeID
817 };
818
820 DefBitmaskEnum(Attribute)
821
822
823 namespace Clusters
825 {
826
827 // !\see Microsoft FAT Specification Section 3.2 。
829 yconstexpr const size_t PerFAT12(4085);
830 yconstexpr const size_t PerFAT16(65525);
832
833 enum : ClusterIndex
834 {
835 FAT16RootDirectory = 0,
841 MaxValid12 = 0xFF6,
842 MaxValid16 = 0xFFF6,
843 MaxValid32 = 0xFFFFFF6,
844 Bad12 = 0xFF7,
845 Bad16 = 0xFFF7,
846 Bad32 = 0xFFFFFF7,
847 EndOfFile12 = 0xFFF,
848 EndOfFile16 = 0xFFFF,
849 EndOfFile32 = 0xFFFFFFFF,
851 EndOfFile = 0x0FFFFFFF,
852 First = 0x00000002,
853 Root = 0x00000000,
854 Free = 0x00000000,
855 Error = 0xFFFFFFFF
856 };
857
859 inline PDefH(bool, IsFreeOrEOF, ClusterIndex c) ynothrow
860 ImplRet(c == Clusters::Free || c == Clusters::EndOfFile)
861
862 } // namespace Clusters;
863
864
866 const char IllegalAliasCharacters[]{"\\/:;*?\"<>|&+,=[] "};
867
868
870 using FileSize = std::uint32_t;
871
876 static yconstexpr const auto MaxFileSize(FileSize(0xFFFFFFFF));
877
878
880 using Timestamp = std::uint16_t;
881
883 YF_API std::time_t
884 ConvertFileTime(Timestamp, Timestamp) ynothrow;
885
887 YF_API pair<Timestamp, Timestamp>
888 FetchDateTime() ynothrow;
889
890
896 namespace LFN
897 {
898
900 enum Offsets
901 {
903 Ordinal = 0x00,
904 Char0 = 0x01,
905 Char1 = 0x03,
906 Char2 = 0x05,
907 Char3 = 0x07,
908 Char4 = 0x09,
910 Flag = 0x0B,
912 Reserved1 = 0x0C,
914 CheckSum = 0x0D,
915 Char5 = 0x0E,
916 Char6 = 0x10,
917 Char7 = 0x12,
918 Char8 = 0x14,
919 Char9 = 0x16,
920 Char10 = 0x18,
922 Reserved2 = 0x1A,
923 Char11 = 0x1C,
924 Char12 = 0x1E
925 };
926
928 yconstexpr const size_t OffsetTable[]{0x01, 0x03, 0x05, 0x07, 0x09, 0x0E,
929 0x10, 0x12, 0x14, 0x16, 0x18, 0x1C, 0x1E};
930
931 enum : size_t
932 {
934 #if YCL_DS
935 MaxLength = 255,
936 #else
937 MaxLength = 256,
938 #endif
939 #if YCL_DS
941 MaxMBCSLength = 255,
942 #else
943 MaxMBCSLength = MaxLength * 3,
944 #endif
945 EntryLength = size(OffsetTable),
946 AliasEntryLength = 11,
947 MaxAliasMainPartLength = 8,
948 MaxAliasExtensionLength = 3,
949 MaxAliasLength = MaxAliasMainPartLength + MaxAliasExtensionLength + 2,
950 MaxNumericTail = 999999
951 };
952
953 enum EntryValues : EntryDataUnit
954 {
956 CaseLowerBasename = 0x08,
958 CaseLowerExtension = 0x10,
960 LastLongEntry = 0x40
961 };
962
964 const char IllegalCharacters[]{"\\/:*?\"<>|"};
965
967
968
975 YF_API tuple<string, string, bool>
976 ConvertToAlias(const u16string&);
977
979 inline PDefH(size_t, FetchLongNameOffset, EntryDataUnit ord) ynothrow
980 ImplRet((size_t(ord & ~LastLongEntry) - 1U) * EntryLength)
982
987 YF_API string
988 ConvertToMBCS(const char16_t* path);
989
995 YF_API YB_NONNULL(1) EntryDataUnit
996 GenerateAliasChecksum(const EntryDataUnit*) ynothrowv;
997
1003 YF_API bool
1004 ValidateName(string_view) ynothrowv;
1005
1011 YF_API void
1012 WriteNumericTail(string&, size_t) ynothrowv;
1013
1014 } // namespace LFN;
1015
1017
1018 yconstexpr const size_t EntryDataSize(0x20);
1020
1025 class YF_API EntryData final : private array<EntryDataUnit, EntryDataSize>
1026 {
1027 public:
1028 using Base = array<EntryDataUnit, EntryDataSize>;
1033 enum Offsets : size_t
1034 {
1035 Name = 0x00,
1036 Extension = 0x08,
1037 Attributes = 0x0B,
1039 CaseInfo = 0x0C,
1040 CTimeTenth = 0x0D,
1041 CTime = 0x0E,
1042 CDate = 0x10,
1043 ADate = 0x12,
1044 ClusterHigh = 0x14,
1045 MTime = 0x16,
1046 MDate = 0x18,
1047 Cluster = 0x1A,
1048 FileSize = 0x1C
1049 };
1051 enum : EntryDataUnit
1052 {
1053 Last = 0x00,
1054 Free = 0xE5,
1055 };
1056
1057 using Base::operator[];
1058 using Base::data;
1059
1060 DefPred(const ynothrow, Directory,
1061 bool(Attribute((*this)[Attributes]) & Attribute::Directory))
1062 DefPred(const ynothrow, LongFileName,
1063 Attribute((*this)[Attributes]) == Attribute::LongFileName)
1064 DefPred(const ynothrow, Volume, bool(Attribute((*this)[Attributes])
1065 & Attribute::VolumeID))
1066 DefPred(const ynothrow, Writable,
1067 !bool(Attribute((*this)[Attributes]) & Attribute::ReadOnly))
1068
1069 PDefH(void, SetDirectoryAttribute, ) ynothrow
1070 ImplExpr((*this)[Attributes] = EntryDataUnit(Attribute::Directory))
1071 PDefH(void, SetDot, size_t n) ynothrowv
1072 ImplExpr(YAssert(n < EntryDataSize, "Invalid argument found."),
1073 (*this)[n] = '.')
1074
1075 PDefH(void, Clear, ) ynothrow
1076 ImplExpr(ystdex::trivially_fill_n(static_cast<Base*>(this)))
1077
1078 PDefH(void, ClearAlias, ) ynothrow
1079 ImplExpr(ystdex::trivially_fill_n(data(), LFN::AliasEntryLength, ' '))
1080
1085 void
1086 CopyLFN(char16_t*) const ynothrowv;
1087
1088 PDefH(void, FillLast, ) ynothrow
1089 ImplExpr(ystdex::trivially_fill_n(static_cast<Base*>(this), 1, Last))
1090
1101 pair<EntryDataUnit, size_t>
1102 FillNewName(string_view, std::function<bool(string_view)>);
1103
1108 bool
1109 FindAlias(string_view) const;
1110
1111 string
1112 GenerateAlias() const;
1113
1114 PDefH(std::uint32_t, ReadFileSize, ) ynothrow
1115 ImplRet(ystdex::read_uint_le<32>(data() + FileSize))
1116
1117 void
1118 SetupRoot(ClusterIndex) ynothrow;
1119
1120 void
1121 WriteAlias(const string&) ynothrow;
1122
1123 void
1124 WriteCDateTime() ynothrow;
1125
1126 void
1127 WriteCluster(ClusterIndex) ynothrow;
1128
1129 void
1130 WriteDateTime() ynothrow;
1131 };
1133
1134
1142 YF_API YB_NONNULL(1) YB_PURE const char*
1143 CheckColons(const char*);
1144
1145 } // namespace FAT;
1146
1147 } // namespace platform;
1148
1149 namespace platform_ex
1150 {
1151
1152 } // namespace platform_ex;
1153
1154 #endif
1155
platform::FAT::FAT32::BPB_FSVer
Definition: YCLib/FileSystem.h:762
platform::FAT::FAT32::BPB_ExtFlags
Definition: YCLib/FileSystem.h:761
platform::DirectorySession::dir
unique_ptr_from< Deleter > dir
Definition: YCLib/FileSystem.h:508
platform::DirectorySession::Data
void Data
Definition: YCLib/FileSystem.h:476
platform::FAT::BPB_RootEntCnt
Definition: YCLib/FileSystem.h:710
platform::FAT::BPB_RsvdSecCnt
Definition: YCLib/FileSystem.h:708
platform::path
_tString && path
Definition: YCLib/FileSystem.h:285
platform::FAT::VolumeLabel
array< byte, 11 > VolumeLabel
卷标数据类型。
Definition: YCLib/FileSystem.h:783
platform::FAT::LFN::EntryLength
Definition: YCLib/FileSystem.h:945
platform::FAT::FAT32::BPB_RootClus
Definition: YCLib/FileSystem.h:763
platform::DirectorySession::Deleter
Definition: YCLib/FileSystem.h:482
platform::FAT::FAT32::BS_FilSysType
Definition: YCLib/FileSystem.h:772
DefPred
#define DefPred(_q, _n,...)
Definition: YBaseMacro.h:232
platform::HDirectory
目录句柄：表示打开的目录和内容迭代状态。
Definition: YCLib/FileSystem.h:562
platform::FAT::BS_jmpBoot
Definition: YCLib/FileSystem.h:704
yconstfn
#define yconstfn
指定编译时常量函数。
Definition: ydef.h:680
platform::FAT::LFN::Reserved2
Definition: YCLib/FileSystem.h:922
DefBitmaskEnum
#define DefBitmaskEnum(_tEnum)
Definition: YBaseMacro.h:481
platform::FAT::IllegalAliasCharacters
const char IllegalAliasCharacters[]
非法别名字符。
Definition: YCLib/FileSystem.h:866
platform::FAT::LFN::CaseLowerExtension
WinNT 小写扩展名。
Definition: YCLib/FileSystem.h:958
platform::FAT::LFN::OffsetTable
yconstexpr const size_t OffsetTable[]
组成长文件名中的 UCS-2 字符在项中的偏移量表。
Definition: YCLib/FileSystem.h:928
platform::FAT::LFN::MaxMBCSLength
UTF-8 项最大长度。
Definition: YCLib/FileSystem.h:943
platform::containers::u16string
basic_string< char16_t > u16string
Definition: Container.h:103
platform::FAT::LFN::ValidateName
YF_API bool ValidateName(string_view) ynothrowv
检查名称是否为合法的可被 UCS-2 表示的非控制字符组成。
Definition: YCLib/FileSystem.cpp:590
platform::IsColon
yconstfn bool IsColon(_tChar c) ynothrow
Definition: YCLib/FileSystem.h:59
platform::YCL_DefPlatformFwdTmpl
YCL_DefPlatformFwdTmpl(IsSeparator, IsSeparator_P) template< typename _tChar > inline YB_NONNULL(2) bool IsAbsolute_P(IDTag< YF_Platform_DS > tag
判断指定路径字符串是否表示一个绝对路径。
platform::tail
_tString ystdex::string_traits< _tString >::const_pointer tail
Definition: YCLib/FileSystem.h:286
DefBoolNeg
#define DefBoolNeg(_spec,...)
定义表示显式转换 bool 操作符及其否定的 operator! 。
Definition: YBaseMacro.h:228
iterator.hpp
通用迭代器。
ystdex::string_traits::const_pointer
const value_type * const_pointer
Definition: string.hpp:70
platform
默认平台命名空间。
Definition: Container.h:47
platform::FAT::BPB_Media
Definition: YCLib/FileSystem.h:712
platform::Deref
yconstfn auto Deref(_type &&p) -> decltype(*p)
断言并解引用非空指针。
Definition: Debug.h:451
platform::FAT::FAT32::BS_Reserved1
Definition: YCLib/FileSystem.h:768
platform::size_t
YF_API size_t
Definition: FileIO.h:1353
platform::FAT::FAT16::BPB
BPB
FAT12 和 FAT16 扩展 BIOS 参数块偏移量。
Definition: YCLib/FileSystem.h:735
ystdex::trivially_fill_n
_type * trivially_fill_n(_type *first, size_t n=1, byte value={})
填充字节序列。
Definition: algorithm.hpp:369
platform_ex::Windows::Device
Definition: MinGW32.h:454
platform::FileMappingOption::ReadOnly
platform::FAT::LFN::Char7
Definition: YCLib/FileSystem.h:917
platform::FAT::FAT32::BS_BootSig
Definition: YCLib/FileSystem.h:769
platform::FAT::BPB_FATSz16
Definition: YCLib/FileSystem.h:713
YF_Platform_Win32
#define YF_Platform_Win32
Win32 平台。
Definition: Platform.h:136
platform::FAT::FSI
FSI
文件系统信息块偏移量。
Definition: YCLib/FileSystem.h:788
platform::FAT::LFN::MaxAliasMainPartLength
Definition: YCLib/FileSystem.h:947
platform::FAT::LFN::Char0
Definition: YCLib/FileSystem.h:904
platform::FAT::MinSectorSize
yconstexpr const size_t MinSectorSize(512)
BIOS 参数块偏移量域 BPB_BytsPerSec 的最值。
platform::bool
std::FILE *fp bool
Definition: FileIO.h:1280
platform::FAT::LFN::LastLongEntry
Ordinal 中标记结束的项。
Definition: YCLib/FileSystem.h:960
DefDeMoveCtor
#define DefDeMoveCtor(_t)
Definition: YBaseMacro.h:167
platform::PDefH
const string const char *sig PDefH(string, ComposeMessageWithSignature, const char *msg, const char *sig) ImplRet(string(Nonnull(msg))+" @ "+Nonnull(sig)) template< class _type > inline YB_NONNULL(2) string ComposeMessageWithSignature(const _type &msg
YAssertNonnull
#define YAssertNonnull(_expr)
Definition: cassert.h:120
platform::IsDirectory
bool IsDirectory(const char *path)
Definition: YCLib/FileSystem.cpp:141
platform::FAT::BPB_SecPerClus
Definition: YCLib/FileSystem.h:707
platform::DirectorySession::sDirPath
string sDirPath
目录路径。
Definition: YCLib/FileSystem.h:503
platform::FAT::FAT32::BPB_Reserved
Definition: YCLib/FileSystem.h:766
platform::FAT::LFN::Char6
Definition: YCLib/FileSystem.h:916
yconstexpr
#define yconstexpr
指定编译时常量表达式。
Definition: ydef.h:679
platform::containers::string
basic_string< char > string
Definition: Container.h:101
ystdex::is_undereferenceable
bool is_undereferenceable(const _tIter &)
Definition: deref_op.hpp:45
platform::KeyCategory::Character
表示产生字符的键。
Definition: Keys.h:111
ystdex::data
auto data(_tRange &c) -> decltype(c.data())
Definition: range.hpp:280
platform::FetchSeparator
yconstfn YB_STATELESS _tChar FetchSeparator() ynothrow
Definition: YCLib/FileSystem.h:90
platform::ImplRet
const string const char *sig ImplRet(msg+" @ "+Nonnull(sig)) inline YB_NONNULL(1
platform::FAT::FAT16::_reserved_remained
Definition: YCLib/FileSystem.h:745
YCL_Tag_constfn
#define YCL_Tag_constfn
包含平台标签的常量表达式函数。
Definition: YCommon.h:112
ystdex::cpp2011::end
_type * end(_type(&&array)[_vN])
Definition: range.hpp:54
platform::FAT::EntryData::Offsets
Offsets
目录项偏移量。
Definition: YCLib/FileSystem.h:1033
platform::FAT::LFN::Char9
Definition: YCLib/FileSystem.h:919
platform::IsAbsolute_P
bool IsAbsolute_P(IDTag< YF_Platform_DS > tag, basic_string_view< _tChar > path) ynothrowv
Definition: YCLib/FileSystem.h:141
YB_PURE
#define YB_PURE
指示函数或函数模板实例为纯函数。
Definition: ydef.h:527
platform::FAT::LFN::WriteNumericTail
YF_API void WriteNumericTail(string &, size_t) ynothrowv
在指定字符串写前缀字符 '~' 和整数的后缀以作为短文件名。
Definition: YCLib/FileSystem.cpp:600
platform::FAT::FileSize
std::uint32_t FileSize
文件大小：字节数。
Definition: YCLib/FileSystem.h:870
platform::FAT::FSI_Free_Count
Definition: YCLib/FileSystem.h:793
platform::FAT::BS_OEMName
Definition: YCLib/FileSystem.h:705
platform::FAT::Attribute::LongFileName
platform::FAT::LFN::IllegalCharacters
const char IllegalCharacters[]
非法长文件名字符。
Definition: YCLib/FileSystem.h:964
platform::FAT::FAT32::BS_DrvNum
Definition: YCLib/FileSystem.h:767
platform::FAT::BPB_TotSec32
Definition: YCLib/FileSystem.h:717
YB_ATTR_returns_nonnull
#define YB_ATTR_returns_nonnull
指示返回非空属性。
Definition: ydef.h:413
platform::CreateSymbolicLink
void CreateSymbolicLink(const char *dst, const char *src, bool is_dir)
Definition: YCLib/FileSystem.cpp:198
platform::FAT::LFN::Char1
Definition: YCLib/FileSystem.h:905
platform::FAT::BPB_TotSec16
Definition: YCLib/FileSystem.h:711
platform::FAT::MaxFileSize
static yconstexpr const auto MaxFileSize(FileSize(0xFFFFFFFF))
最大文件大小。
platform::FAT::BPB_NumHeads
Definition: YCLib/FileSystem.h:715
platform::DirectorySession::Deleter::pointer
NativeHandle pointer
Definition: YCLib/FileSystem.h:488
YAssert
#define YAssert(_expr, _msg)
Definition: cassert.h:111
DefDeMoveAssignment
#define DefDeMoveAssignment(_t)
Definition: YBaseMacro.h:191
platform::FAT::LFN::Ordinal
长文件名序数。
Definition: YCLib/FileSystem.h:903
platform::ReadLink
string ReadLink(const char *path)
Definition: YCLib/FileSystem.cpp:229
platform::FAT::LFN::Char12
Definition: YCLib/FileSystem.h:924
platform::FAT::FSI_Nxt_Free
Definition: YCLib/FileSystem.h:794
platform::FAT::LFN::CaseLowerBasename
WinNT 小写文件名。
Definition: YCLib/FileSystem.h:956
platform::IsSeparator_P
YCL_Tag_constfn YB_STATELESS bool IsSeparator_P(IDTag< YF_Platform_Win32 > tag, _tChar c) ynothrow
Definition: YCLib/FileSystem.h:100
platform::if
if(!p) p
platform::FAT::EntryData::Base
array< EntryDataUnit, EntryDataSize > Base
Definition: YCLib/FileSystem.h:1028
ystdex
特性测试宏。
Definition: ydef.h:822
DefDeDtor
#define DefDeDtor(_t)
Definition: YBaseMacro.h:177
platform::FAT::EntryData
目录项数据。
Definition: YCLib/FileSystem.h:1025
platform::FAT::LFN::ConvertToMBCS
string ConvertToMBCS(const char16_t *path)
Definition: YCLib/FileSystem.cpp:568
YSLib::i
return i
Definition: YCoreUtilities.h:176
platform::DirectorySession::DirectorySession
DirectorySession()
构造：打开目录路径。
Definition: YCLib/FileSystem.cpp:345
platform::FAT::LFN::Char8
Definition: YCLib/FileSystem.h:918
platform_ex::Windows::Invalid
Definition: MinGW32.h:471
platform::FAT::LFN::AliasEntryLength
Definition: YCLib/FileSystem.h:946
platform::ynothrowv
YF_API int amode ynothrowv
Definition: FileIO.h:528
YF_API
#define YF_API
Definition: Platform.h:56
platform::FAT::LFN::Char5
Definition: YCLib/FileSystem.h:915
platform::FAT::FAT16::Signature_word
Definition: YCLib/FileSystem.h:744
platform::YB_NONNULL
YB_NONNULL(2) PDefH(string
组合消息和函数签名字符串。
platform::FAT::FSI_StrucSig_Value
yconstexpr const std::uint32_t FSI_StrucSig_Value(0x61417272)
YModules.h
platform::DirectorySession
目录会话：表示打开的目录。
Definition: YCLib/FileSystem.h:468
ystdex::read_uint_le
make_width_int< _vWidth >::unsigned_type read_uint_le(const byte *buf)
从字节缓冲区读取指定宽的小端序无符号整数。
Definition: cstdint.hpp:328
platform::FAT::FetchDateTime
YF_API pair< Timestamp, Timestamp > FetchDateTime() ynothrow
取以实时时钟的文件日期和时间。
Definition: YCLib/FileSystem.cpp:635
platform::FAT::FAT32::BPB_FSInfo
Definition: YCLib/FileSystem.h:764
platform::FAT::FSI_Reserved2
Definition: YCLib/FileSystem.h:795
platform::FAT::FSI_TrailSig
Definition: YCLib/FileSystem.h:796
platform::FAT::FAT32::BPB_FATSz32
Definition: YCLib/FileSystem.h:760
base.h
基类实用设施。
YF_Platform_DS
#define YF_Platform_DS
目标平台标识。
Definition: Platform.h:130
platform::FAT::BPB_SecPerTrk
Definition: YCLib/FileSystem.h:714
platform::FAT::LFN::MaxNumericTail
Definition: YCLib/FileSystem.h:950
YSLib::Drawing::ImageFormat::Unknown
platform::FAT::FAT32::_reserved_zero_420
Definition: YCLib/FileSystem.h:773
YSLib::Drawing::FontStyle::Regular
常规字体。
platform::FAT::Attribute
Attribute
文件属性。
Definition: YCLib/FileSystem.h:808
ystdex::rtrim
_tString && rtrim(_tString &&str, typename string_traits< _tString >::value_type c)
删除字符串中指定的连续后缀字符。
Definition: string.hpp:676
platform::FAT::Timestamp
std::uint16_t Timestamp
时间戳：表示日期和时间的整数类型。
Definition: YCLib/FileSystem.h:880
platform::FAT::FAT32::BS_VolLab
Definition: YCLib/FileSystem.h:771
ystdex::to_array
std::array< _type, _vN > to_array(const _tSrc &src)
转换指定参数为 std::array 对象。
Definition: array.hpp:87
platform::FAT::BPB_NumFATs
Definition: YCLib/FileSystem.h:709
platform::FAT::BPB
BPB
BIOS 参数块偏移量。
Definition: YCLib/FileSystem.h:702
platform::FAT::BPB_HiddSec
Definition: YCLib/FileSystem.h:716
platform::FAT::LFN::Char4
Definition: YCLib/FileSystem.h:908
platform::FAT::LFN::Char2
Definition: YCLib/FileSystem.h:906
platform::FetchRootNameLength_P
size_t FetchRootNameLength_P(IDTag< YF_Platform_DS >, basic_string_view< _tChar > path) ynothrowv
Definition: YCLib/FileSystem.h:202
cstdint.hpp
ISO C 标准整数类型和相关扩展操作。
platform::FAT::CheckColons
const char * CheckColons(const char *path)
Definition: YCLib/FileSystem.cpp:849
std
Definition: memory.hpp:1183
platform::IDTagBase
平台标识的公共标记类型：指定任意平台。
Definition: YCommon.h:59
platform::DirectorySession::NativeHandle
Data * NativeHandle
Definition: YCLib/FileSystem.h:478
DefGetter
#define DefGetter(_q, _t, _n,...)
Definition: YBaseMacro.h:241
platform::Nonnull
_type && Nonnull(_type &&p) ynothrowv
断言并返回非空参数。
Definition: Debug.h:422
platform::FAT::LFN::ConvertToAlias
YF_API tuple< string, string, bool > ConvertToAlias(const u16string &)
转换长文件名为别名。
Definition: YCLib/FileSystem.cpp:509
platform::FAT::LFN::MaxLength
UCS-2 项最大长度。
Definition: YCLib/FileSystem.h:937
ystdex::ntctschr
_tChar * ntctschr(_tChar *s, remove_const_t< _tChar > c)
在简单 NTCTS 内查找字符。
Definition: cstring.h:393
DefCvt
#define DefCvt(_q, _t,...)
Definition: YBaseMacro.h:206
platform::FAT::LFN::Flag
Definition: YCLib/FileSystem.h:910
YB_NORETURN
#define YB_NORETURN
指定无返回值函数。
Definition: ydef.h:504
platform::HDirectory::NativeChar
char NativeChar
Definition: YCLib/FileSystem.h:576
platform::FAT::FSI_TrailSig_Value
yconstexpr const std::uint32_t FSI_TrailSig_Value(0xAA550000)
platform_ex
平台扩展命名空间。
Definition: Android.h:45
platform::CreateHardLink
void CreateHardLink(const char *dst, const char *src)
Definition: YCLib/FileSystem.cpp:167
platform::FetchSeparator_P
YCL_Tag_constfn YB_STATELESS _tChar FetchSeparator_P(IDTag< YF_Platform_Win32 >) ynothrow
Definition: YCLib/FileSystem.h:77
platform::FAT::LFN::Reserved1
Definition: YCLib/FileSystem.h:912
platform::FAT::LFN::Offsets
Offsets
长文件名目录项偏移量。
Definition: YCLib/FileSystem.h:900
platform::FAT::LFN::Char11
Definition: YCLib/FileSystem.h:923
platform::FAT::ClusterIndex
std::uint32_t ClusterIndex
Definition: YCLib/FileSystem.h:695
platform::FAT::BPB_BytsPerSec
Definition: YCLib/FileSystem.h:706
platform::KeyCodes::Win32::Empty
Definition: Keys.h:279
platform::IDTag< YF_Platform_Win32 >
Definition: YCommon.h:91
CHRLib::c
c
Definition: CharacterProcessing.h:81
ystdex::indirect_input_iterator
间接输入迭代器。
Definition: iterator.hpp:822
yforward
#define yforward(_expr)
根据参数类型使用 std::forward 传递对应参数。
Definition: ydef.h:995
platform::IterateLink
YF_API bool IterateLink(string &, size_t &)
迭代访问链接：替换非空路径并按需减少允许链接计数。
Definition: YCLib/FileSystem.cpp:303
CHRLib::char16_t
char16_t((*c_ptr<< CHAR_BIT)|c_ptr[1])) inline PDefH(char16_t
取 c_ptr 指向的小端序双字节字符。
platform::FAT::LFN::MaxAliasLength
Definition: YCLib/FileSystem.h:949
platform::FAT::FAT32::BPB
BPB
FAT32 扩展 BIOS 参数块偏移量。
Definition: YCLib/FileSystem.h:758
platform::FAT::LFN::EntryValues
EntryValues
Definition: YCLib/FileSystem.h:953
ystdex::cpp2011::begin
_type * begin(_type(&&array)[_vN])
Definition: range.hpp:46
platform::FAT::FAT32::BS_VolID
Definition: YCLib/FileSystem.h:770
platform::FAT::ConvertFileTime
YF_API std::time_t ConvertFileTime(Timestamp, Timestamp) ynothrow
转换日期和时间的时间戳为标准库时间类型。
Definition: YCLib/FileSystem.cpp:618
ystdex::string_traits::value_type
remove_rcv_t< decltype(std::declval< string_type >()[0])> value_type
Definition: string.hpp:58
ystdex::size
auto size(const _tRange &c) -> decltype(c.size())
类容器访问。
Definition: range.hpp:233
platform::FAT::EntryDataUnit
std::uint8_t EntryDataUnit
Definition: YCLib/FileSystem.h:694
platform::FAT::FAT16::_reserved_zero_448
Definition: YCLib/FileSystem.h:743
platform::FAT::LFN::GenerateAliasChecksum
EntryDataUnit GenerateAliasChecksum(const EntryDataUnit *p) ynothrowv
Definition: YCLib/FileSystem.cpp:576
platform::FAT::LFN::Char3
Definition: YCLib/FileSystem.h:907
platform::FAT::FSI_LeadSig
Definition: YCLib/FileSystem.h:790
platform::FAT::LFN::MaxAliasExtensionLength
Definition: YCLib/FileSystem.h:948
platform::FAT::FSI_Reserved1
Definition: YCLib/FileSystem.h:791
platform::FAT::LFN::Char10
Definition: YCLib/FileSystem.h:920
platform::FAT::FAT32::BPB_BkBootSec
Definition: YCLib/FileSystem.h:765
platform::FAT::FSI_LeadSig_Value
yconstexpr const std::uint32_t FSI_LeadSig_Value(0x41615252)
platform::FAT::MaxSectorSize
yconstexpr const size_t MaxSectorSize(4096)
platform::FAT::EntryDataSize
yconstexpr const size_t EntryDataSize(0x20)
目录项数据大小。
platform::FAT::LFN::CheckSum
短文件名（别名）校验和。
Definition: YCLib/FileSystem.h:914
ystdex::string_view
basic_string_view< char > string_view
Definition: string_view.hpp:415
YSLib::IO::IsAbsolute
IsAbsolute
Definition: YSLib/Service/FileSystem.h:57
CHRLib::p
const auto p(d)
platform::FAT::FSI_StrucSig
Definition: YCLib/FileSystem.h:792
platform_ex::Windows::Directory
Definition: MinGW32.h:452
platform::ynothrow
const _tString &path ynothrow
Definition: YCLib/FileSystem.h:274
YB_STATELESS
#define YB_STATELESS
指示函数或函数模板实例为无状态函数。
Definition: ydef.h:548
platform::IDTag
平台标识的整数标记类型。
Definition: YCommon.h:73
ystdex::details::get
get())
Definition: cast.hpp:102