YSTest: FileSystem.h 源文件

YSTest PreAlpha_b900_20201012 The YSLib Test Project

YCLib/FileSystem.h
浏览该文件的文档.
1 /*
2 © 2011-2020 FrankHB.
3
4 This file is part of the YSLib project, and may only be used,
5 modified, and distributed under the terms of the YSLib project
6 license, LICENSE.TXT. By continuing to use, modify, or distribute
7 this file you indicate that you have read the license and
8 understand and accept it fully.
9 */
10
28 #ifndef YCL_INC_FileSystem_h_
29 #define YCL_INC_FileSystem_h_ 1
30
31 #include "YModules.h"
32 #include YFM_YCLib_Container // for basic_string_view, ystdex::is_null,
33 // string_view_t, ystdex::exclude_self_t, std::wint_t, ystdex::to_array,
34 // ystdex::string_traits, ystdex::rtrim, string, u16string, std::uint8_t,
35 // std::uint32_t, std::memcmp, pair, size, tuple;
36 #include YFM_YCLib_Reference // for unique_ptr_from, tidy_ptr;
37 #include <system_error> // for std::system_error;
38 #include <ystdex/base.h> // for ystdex::deref_self;
39 #include <ystdex/iterator.hpp> // for ystdex::indirect_input_iterator;
40 #include <ctime> // for std::time_t;
41 #include YFM_YCLib_Debug // for Nonnull, Deref;
42 #include <ystdex/function.hpp> // for ystdex::function;
43 #include <ystdex/type_pun.hpp> // for ystdex::is_trivially_replaceable;
44 #include <ystdex/cstdint.hpp> // for ystdex::read_uint_le;
45
46 #if !YCL_Win32 && !YCL_API_POSIXFileSystem
47 # error "Unsupported platform found."
48 #endif
49
50 #if !YCL_Win32
51 struct dirent;
53 #endif
54
55 namespace platform
56 {
57
59
60 template<typename _tChar>
61 YB_ATTR_nodiscard YB_STATELESS yconstfn bool
62 IsColon(_tChar c) ynothrow
63 {
64 return c == _tChar(':');
65 }
66
67 template<typename _tChar>
68 YB_ATTR_nodiscard YB_PURE YB_NONNULL(1) inline const _tChar*
69 FindColon(const _tChar* p) ynothrowv
70 {
71 return ystdex::ntctschr(Nonnull(p), _tChar(':'));
72 }
73
75
76
78 template<typename _tChar>
79 YB_STATELESS YCL_Tag_constfn _tChar
80 FetchSeparator_P(IDTag<YF_Platform_Win32>) ynothrow
81 {
82 return '\\';
83 }
84 template<typename _tChar>
85 YB_STATELESS YCL_Tag_constfn _tChar
86 FetchSeparator_P(IDTagBase) ynothrow
87 {
88 return '/';
89 }
90
91 template<typename _tChar>
92 YB_STATELESS yconstfn _tChar
93 FetchSeparator() ynothrow
94 {
95 return FetchSeparator_P<_tChar>(IDTag<YF_Platform>());
96 }
98
100
101 template<typename _tChar>
102 YB_STATELESS YCL_Tag_constfn bool
103 IsSeparator_P(IDTag<YF_Platform_Win32> tag, _tChar c) ynothrow
104 {
105 return c == FetchSeparator_P<_tChar>(tag) || c == _tChar('/');
106 }
107 template<typename _tChar>
108 YB_STATELESS YCL_Tag_constfn bool
109 IsSeparator_P(IDTagBase tag, _tChar c) ynothrow
110 {
111 return c == FetchSeparator_P<_tChar>(tag);
112 }
113
114 YCL_DefPlatformFwdTmpl(IsSeparator, IsSeparator_P)
116
117
134 template<typename _tChar>
135 YB_ATTR_nodiscard YB_PURE YB_NONNULL(2) inline bool
136 IsAbsolute_P(IDTag<YF_Platform_DS> tag, const _tChar* path) ynothrowv
137 {
138 // XXX: Separator used in root.
139 return
140 platform::IsSeparator_P(tag, Deref(path)) || platform::FindColon(path);
141 }
142 template<typename _tChar>
143 YB_ATTR_nodiscard YB_PURE inline bool
144 IsAbsolute_P(IDTag<YF_Platform_DS> tag, basic_string_view<_tChar> path)
145 ynothrowv
146 {
147 // XXX: Separator used in root.
148 YAssertNonnull(path.data());
149 return !path.empty() && (platform::IsSeparator_P(tag, path.front())
150 || path.find(_tChar(':')) != basic_string_view<_tChar>::npos);
151 }
152 template<typename _tChar>
153 YB_ATTR_nodiscard YB_PURE YB_NONNULL(2) inline bool
154 IsAbsolute_P(IDTag<YF_Platform_Win32> tag, const _tChar* path) ynothrowv
155 {
156 return platform::IsSeparator_P(tag, Deref(path))
157 || (!ystdex::is_null(*path) && IsColon(*++path));
158 }
159 template<typename _tChar>
160 YB_ATTR_nodiscard YB_PURE inline bool
161 IsAbsolute_P(IDTag<YF_Platform_Win32> tag, basic_string_view<_tChar> path)
162 ynothrowv
163 {
164 YAssertNonnull(path.data());
165 return path.length() > 1
166 && (platform::IsSeparator_P(tag, path.front()) || IsColon(path[1]));
167 }
168 template<typename _tChar>
169 YB_ATTR_nodiscard YB_PURE YB_NONNULL(2) inline bool
170 IsAbsolute_P(IDTagBase tag, const _tChar* path) ynothrowv
171 {
172 return platform::IsSeparator_P(tag, Deref(path));
173 }
174 template<typename _tChar>
175 YB_ATTR_nodiscard YB_PURE inline bool
176 IsAbsolute_P(IDTagBase tag, basic_string_view<_tChar> path) ynothrowv
177 {
178 YAssertNonnull(path.data());
179 return !path.empty() && platform::IsSeparator_P(tag, path.front());
180 }
181
183 YCL_DefPlatformFwdTmpl(IsAbsolute, IsAbsolute_P)
185
186 #define YCL_Impl_DefPlatformStringFwdTmpl(_fn) \
187 template<class _tTag, class _tString> \
188 inline auto \
189 _fn(_tTag tag, const _tString& path) ynothrowv \
190 -> ystdex::exclude_self_t<string_view_t<_tString>, _tString, \
191 decltype(platform::_fn(tag, string_view_t<_tString>(path)))> \
192 { \
193 return platform::_fn(tag, string_view_t<_tString>(path)); \
194 }
195
202 template<typename _tChar>
203 YB_ATTR_nodiscard YB_ATTR_returns_nonnull YB_NONNULL(2) YB_PURE inline
204 const _tChar*
205 FetchRootNameEnd_P(IDTag<YF_Platform_DS>, const _tChar* path) ynothrowv
206 {
207 const auto p(platform::FindColon(path));
208
209 return p ? p : path;
210 }
211 template<typename _tChar>
212 YB_ATTR_nodiscard YB_PURE YB_NONNULL(2) inline const _tChar*
213 FetchRootNameEnd_P(IDTag<YF_Platform_Win32>, const _tChar*) ynothrowv;
214 template<class _tTag, typename _tChar>
215 YB_ATTR_nodiscard YB_PURE typename basic_string_view<_tChar>::const_iterator
216 FetchRootNameEnd_P(_tTag, basic_string_view<_tChar>) ynothrowv;
217 template<typename _tChar>
218 YB_ATTR_nodiscard YB_PURE YB_NONNULL(2) inline const _tChar*
219 FetchRootNameEnd_P(IDTagBase, const _tChar*) ynothrowv;
220 YCL_Impl_DefPlatformStringFwdTmpl(FetchRootNameEnd_P)
221
222 YCL_DefPlatformFwdTmpl(FetchRootNameEnd, FetchRootNameEnd_P)
224
230 template<typename _tChar>
231 YB_ATTR_nodiscard YB_PURE YB_NONNULL(2) inline size_t
232 FetchRootNameLength_P(IDTag<YF_Platform_DS> tag, const _tChar* path) ynothrowv
233 {
234 return size_t(platform::FetchRootNameEnd_P(tag, path) - path);
235 }
236 template<typename _tChar>
237 YB_ATTR_nodiscard YB_PURE size_t
238 FetchRootNameLength_P(IDTag<YF_Platform_DS>, basic_string_view<_tChar> path)
239 ynothrowv
240 {
241 YAssertNonnull(path.data());
242
243 auto n(path.find_first_of(_tChar(':')));
244
245 return n != basic_string_view<_tChar>::npos ? n : 0;
246 }
247 template<typename _tChar>
248 YB_ATTR_nodiscard YB_PURE YB_NONNULL(2) size_t
249 FetchRootNameLength_P(IDTag<YF_Platform_Win32> tag, const _tChar* path)
250 ynothrowv
251 {
252 if(!ystdex::is_null(path[0]))
253 {
254 // XXX: Conversion to 'std::wint_t' might be implementation-defined.
255 if(IsColon(path[1]) && std::iswalpha(std::wint_t(path[0])))
256 return 2;
257 if(platform::IsSeparator_P(tag, path[0]) && !ystdex::is_null(path[1])
258 && !ystdex::is_null(path[2]))
259 {
260 // NOTE: UNC name with prefix of form '\\?\', '\\.\' or '\??\'.
261 if(!ystdex::is_null(path[3]) && platform::IsSeparator_P(tag,
262 path[3]) && !platform::IsSeparator_P(tag, path[4])
263 && ((platform::IsSeparator_P(tag, path[1]) && (path[2] == '?'
264 || path[2] == '.')) || (path[1] == '?' && path[2] == '?')))
265 return 3;
266 // NOTE: UNC name with prefix of form '\\server'.
267 if(platform::IsSeparator_P(tag, path[1])
268 && !platform::IsSeparator_P(tag, path[2]))
269 {
270 auto p(path + 3);
271
272 while(!ystdex::is_null(*p) && !platform::IsSeparator_P(tag, *p))
273 ++p;
274 return p - path;
275 }
276 }
277 }
278 return 0;
279 }
280 template<typename _tChar>
281 YB_ATTR_nodiscard YB_PURE YB_PURE size_t
282 FetchRootNameLength_P(IDTag<YF_Platform_Win32> tag,
283 basic_string_view<_tChar> path) ynothrowv
284 {
285 YAssertNonnull(path.data());
286
287 const auto l(path.size());
288
289 if(l >= 2)
290 {
291 // NOTE: Name with prefix of form 'X:'.
292 // TODO: Memory load can be fused.
293 // XXX: Conversion to 'std::wint_t' might be implementation-defined.
294 if(IsColon(path[1]) && std::iswalpha(std::wint_t(path[0])))
295 return 2;
296 if(platform::IsSeparator_P(tag, path[0]))
297 {
298 // NOTE: UNC name with prefix of form '\\?\', '\\.\' or '\??\'.
299 if(l >= 4 && platform::IsSeparator_P(tag, path[3])
300 && (l == 4 || !platform::IsSeparator_P(tag, path[4]))
301 && ((platform::IsSeparator_P(tag, path[1]) && (path[2] == '?'
302 || path[2] == '.')) || (path[1] == '?' && path[2] == '?')))
303 return 3;
304 // NOTE: UNC name with prefix of form '\\server'.
305 if(l >= 3 && platform::IsSeparator_P(tag, path[1])
306 && !platform::IsSeparator_P(tag, path[2]))
307 // XXX: Use %platform::IsSeparator_P?
308 return std::min(path.find_first_of(&ystdex::to_array<_tChar>(
309 "/\\")[0], 3), path.length());
310 }
311 }
312 return 0;
313 }
314 template<typename _tChar>
315 YB_ATTR_nodiscard YB_PURE YB_NONNULL(2) inline size_t
316 FetchRootNameLength_P(IDTagBase tag, const _tChar* path) ynothrowv
317 {
318 return platform::IsSeparator_P(tag, Deref(path)) ? 1 : 0;
319 }
320 template<typename _tChar>
321 YB_ATTR_nodiscard YB_PURE inline size_t
322 FetchRootNameLength_P(IDTagBase tag, basic_string_view<_tChar> path)
323 ynothrowv
324 {
325 YAssertNonnull(path.data());
326 return !path.empty() && platform::IsSeparator_P(tag, path.front()) ? 1 : 0;
327 }
329 YCL_Impl_DefPlatformStringFwdTmpl(FetchRootNameLength_P)
330
331 YCL_DefPlatformFwdTmpl(FetchRootNameLength, FetchRootNameLength_P)
334
336
337 template<typename _tChar>
338 YB_ATTR_nodiscard YB_PURE YB_NONNULL(2) inline const _tChar*
339 FetchRootNameEnd_P(IDTag<YF_Platform_Win32> tag, const _tChar* path) ynothrowv
340 {
341 return path + platform::FetchRootNameLength_P(tag, path);
342 }
343 template<class _tTag, typename _tChar>
344 YB_ATTR_nodiscard YB_PURE typename basic_string_view<_tChar>::const_iterator
345 FetchRootNameEnd_P(_tTag tag, basic_string_view<_tChar> path) ynothrowv
346 {
347 return path.cbegin() + platform::FetchRootNameLength_P(tag, path);
348 }
349 template<typename _tChar>
350 YB_ATTR_nodiscard YB_PURE YB_NONNULL(2) inline const _tChar*
351 FetchRootNameEnd_P(IDTagBase tag, const _tChar* path) ynothrowv
352 {
353 return path + platform::FetchRootNameLength_P(tag, path);
354 }
355
361 template<typename _tChar>
362 YB_ATTR_nodiscard YB_NONNULL(2) YB_PURE size_t
363 FetchRootPathLength_P(IDTag<YF_Platform_DS> tag, const _tChar* path) ynothrowv
364 {
365 auto p(platform::FindColon(path));
366
367 if(!p)
368 p = path;
369 while(platform::IsSeparator_P(tag, *p))
370 ++p;
371 return size_t(p - path);
372 }
373 template<typename _tChar>
374 YB_ATTR_nodiscard YB_PURE size_t
375 FetchRootPathLength_P(IDTag<YF_Platform_DS>, basic_string_view<_tChar> path)
376 ynothrowv
377 {
378 YAssertNonnull(path.data());
379
380 auto n(path.find_first_of(_tChar(':')));
381
382 if(n != basic_string_view<_tChar>::npos)
383 n = path.find_first_not_of(_tChar('/'), n + 1);
384 return n != basic_string_view<_tChar>::npos ? n : 0;
385 }
386 template<typename _tChar>
387 YB_ATTR_nodiscard YB_NONNULL(2) YB_PURE size_t
388 FetchRootPathLength_P(IDTag<YF_Platform_Win32> tag, const _tChar* path)
389 ynothrowv
390 {
391 const auto l(platform::FetchRootNameLength_P(tag, path));
392
393 if(l > 0)
394 {
395 auto p(path + l);
396
397 // TODO: Extract as %ystdex::tstr_find_first_not_of?
398 while(!ystdex::is_null(*p) && !platform::IsSeparator_P(tag, *p))
399 ++p;
400 return p - path;
401 }
402 return l;
403 }
404 template<typename _tChar>
405 YB_ATTR_nodiscard YB_PURE size_t
406 FetchRootPathLength_P(IDTag<YF_Platform_Win32> tag,
407 basic_string_view<_tChar> path) ynothrowv
408 {
409 const auto l(platform::FetchRootNameLength_P(tag, path));
410
411 if(l > 0)
412 {
413 // XXX: Use %platform::IsSeparator_P?
414 const auto
415 n(path.find_first_not_of(&ystdex::to_array<_tChar>("/\\")[0], l));
416
417 return n != basic_string_view<_tChar>::npos ? n : path.length();
418 }
419 return l;
420 }
421 template<typename _tChar>
422 YB_ATTR_nodiscard YB_NONNULL(2) YB_PURE inline size_t
423 FetchRootPathLength_P(IDTagBase tag, const _tChar* path) ynothrowv
424 {
425 return platform::IsSeparator_P(tag, Deref(path)) ? 1 : 0;
426 }
427 template<typename _tChar>
428 YB_ATTR_nodiscard YB_PURE inline size_t
429 FetchRootPathLength_P(IDTagBase tag, basic_string_view<_tChar> path)
430 ynothrowv
431 {
432 YAssertNonnull(path.data());
433 return !path.empty() && platform::IsSeparator_P(tag, path.front()) ? 1 : 0;
434 }
435 YCL_Impl_DefPlatformStringFwdTmpl(FetchRootPathLength_P)
436
437 YCL_DefPlatformFwdTmpl(FetchRootPathLength, FetchRootPathLength_P)
439
440
441
442 #undef YCL_Impl_DefPlatformStringFwdTmpl
443
450 template<class _tString>
451 YB_ATTR_nodiscard YB_PURE yconstfn bool
452 EndsWithNonSeperator_P(IDTagBase tag, const _tString& path) ynothrow
453 {
454 return !path.empty() && !platform::IsSeparator_P(tag, path.back());
455 }
456
457 YCL_DefPlatformFwdTmpl(EndsWithNonSeperator, EndsWithNonSeperator_P)
459
461
462 template<class _tString>
463 YCL_Tag_constfn _tString&&
464 TrimTrailingSeperator_P(IDTag<YF_Platform_Win32>, _tString&& path, typename
465 ystdex::string_traits<_tString>::const_pointer tail = &ystdex::to_array<
466 typename ystdex::string_traits<_tString>::value_type>("/\\")[0]) ynothrow
467 {
468 return ystdex::rtrim(yforward(path), tail);
469 }
470
471 template<class _tString>
472 YCL_Tag_constfn _tString&&
473 TrimTrailingSeperator_P(IDTagBase, _tString&& path, typename
474 ystdex::string_traits<_tString>::const_pointer tail = &ystdex::to_array<
475 typename ystdex::string_traits<_tString>::value_type>("/")[0]) ynothrow
476 {
477 return ystdex::rtrim(yforward(path), tail);
478 }
479
480 YCL_DefPlatformFwdTmpl(TrimTrailingSeperator, TrimTrailingSeperator_P)
482
483
484
485
489 enum class NodeCategory : std::uint_least32_t
490 {
491 Empty = 0,
493
494 Invalid = 1 << 0,
495 Regular = 1 << 1,
497 Unknown = Invalid | Regular,
499
500 Device = 1 << 9,
501 Block = Device,
502 Character = Device | 1 << 7,
503 Communicator = 2 << 9,
504 FIFO = Communicator | 1 << 6,
505 Socket = Communicator | 2 << 6,
507 SymbolicLink = 1 << 12,
508 MountPoint = 2 << 12,
509 Junction = MountPoint,
511
512 Link = SymbolicLink | Junction,
514 Directory = 1 << 15,
516
517 Missing = 1 << 16,
518 Special = Link | Missing
520 };
521
526 DefBitmaskEnum(NodeCategory)
527
528
529
535 YB_ATTR_nodiscard YF_API YB_NONNULL(1) bool
536 IsDirectory(const char*);
537 YB_ATTR_nodiscard YF_API YB_NONNULL(1) bool
538 IsDirectory(const char16_t*);
540
541
550
552
554
560 #if YCL_DS
561 YB_NORETURN
562 #endif
563 YF_API YB_NONNULL(1, 2) void
564 CreateHardLink(const char*, const char*);
565 #if YCL_DS
566 YB_NORETURN
567 #endif
568 YF_API YB_NONNULL(1, 2) void
569 CreateHardLink(const char16_t*, const char16_t*);
571
580 #if YCL_DS
581 YB_NORETURN
582 #endif
583 YF_API YB_NONNULL(1, 2) void
584 CreateSymbolicLink(const char*, const char*, bool = {});
585 #if YCL_DS
586 YB_NORETURN
587 #endif
588 YF_API YB_NONNULL(1, 2) void
589 CreateSymbolicLink(const char16_t*, const char16_t*, bool = {});
591
592
603 YB_ATTR_nodiscard
604 #if YCL_DS
605 YB_NORETURN
606 #endif
607 YF_API YB_NONNULL(1) string
608 ReadLink(const char*);
609 YB_ATTR_nodiscard
610 #if YCL_DS
611 YB_NORETURN
612 #endif
613 YF_API YB_NONNULL(1) u16string
614 ReadLink(const char16_t*);
616
617
628 #if YCL_DS
629 inline PDefH(bool, IterateLink, string&, size_t&)
630 ImplRet({})
631 inline PDefH(bool, IterateLink, u16string&, size_t&)
632 ImplRet({})
633 #else
634 YF_API bool
635 IterateLink(string&, size_t&);
636 YF_API bool
637 IterateLink(u16string&, size_t&);
638 #endif
639
640
641
642
649 class YF_API DirectorySession
650 {
651 public:
652 #if YCL_Win32
653 class Data;
655 #else
656 using Data = void;
658 #endif
659 using NativeHandle = Data*;
660
661 private:
663 class YF_API Deleter
664 #if YCL_Win32
665 : private default_delete<Data>
666 #endif
667 {
668 public:
669 using pointer = NativeHandle;
670
672 void
673 operator()(pointer) const ynothrowv;
674 };
675
676 #if !YCL_Win32
677 protected:
684 string sDirPath;
685 #endif
686
687 private:
689 unique_ptr_from<Deleter> dir;
690
691 public:
705 DirectorySession();
707 explicit YB_NONNULL(2)
708 DirectorySession(const char*);
709 explicit YB_NONNULL(2)
710 DirectorySession(const char16_t*);
712
716 DefDeMoveCtor(DirectorySession)
721 DefDeDtor(DirectorySession)
722
727 DefDeMoveAssignment(DirectorySession)
728
730 DefGetter(const ynothrow, NativeHandle, NativeHandle, dir.get())
731
733 void
734 Rewind() ynothrow;
735 };
736
737
743 class YF_API HDirectory final
744 : private DirectorySession, private ystdex::deref_self<HDirectory>
745 {
747 friend deref_self<HDirectory>;
748
749 public:
751 using NativeChar =
752 #if YCL_Win32
753 char16_t
754 #else
755 char
756 #endif
757 ;
759 using iterator = ystdex::indirect_input_iterator<HDirectory*>;
760
761 private:
762 #if YCL_Win32
763 u16string dirent_str;
765 #else
766
770 tidy_ptr<::dirent> p_dirent{};
771 #endif
772
773 public:
778 using DirectorySession::DirectorySession;
780 DefDeMoveCtor(HDirectory)
781
782
783 DefDeMoveAssignment(HDirectory)
784
785
790 using ystdex::deref_self<HDirectory>::operator*;
791
796 HDirectory&
797 operator++();
798
803 #if YCL_Win32
804 YB_PURE DefBoolNeg(YB_PURE explicit, !dirent_str.empty())
805 #else
806 YB_PURE DefBoolNeg(YB_PURE explicit, bool(p_dirent))
807 #endif
808
810 YB_ATTR_nodiscard YB_PURE
811 DefCvt(const ynothrow, basic_string_view<NativeChar>, GetNativeName())
813 YB_ATTR_nodiscard YB_PURE
814 operator string() const;
816 YB_ATTR_nodiscard YB_PURE
817 operator u16string() const;
818
825 YB_ATTR_nodiscard NodeCategory
826 GetNodeCategory() const ynothrow;
833 YB_ATTR_nodiscard YB_ATTR_returns_nonnull YB_PURE const NativeChar*
834 GetNativeName() const ynothrow;
835
837 using DirectorySession::Rewind;
838
840
841 YB_ATTR_nodiscard YB_PURE PDefH(iterator, begin, )
842 ImplRet(this)
843
844 YB_ATTR_nodiscard YB_PURE PDefH(iterator, end, )
845 ImplRet(iterator())
847 };
848
854 inline PDefH(bool, is_undereferenceable, const HDirectory& i) ynothrow
855 ImplRet(!i)
856
857
862 enum class FileSystemType
863 {
864 Unknown,
865 FAT12,
866 FAT16,
867 FAT32
868 };
869
870
875 namespace FAT
876 {
877
878 using EntryDataUnit = byte;
879 using ClusterIndex = std::uint32_t;
881 using ClusterCount = std::uint32_t;
882
884 static_assert(ystdex::is_trivially_replaceable<EntryDataUnit, std::uint8_t>(),
885 "Invalid type found.");
886
888
889
891 enum BPB : size_t
893 {
894 BS_jmpBoot = 0,
895 BS_OEMName = 3,
896 BPB_BytsPerSec = 11,
897 BPB_SecPerClus = 13,
898 BPB_RsvdSecCnt = 14,
899 BPB_NumFATs = 16,
900 BPB_RootEntCnt = 17,
901 BPB_TotSec16 = 19,
902 BPB_Media = 21,
903 BPB_FATSz16 = 22,
904 BPB_SecPerTrk = 24,
905 BPB_NumHeads = 26,
906 BPB_HiddSec = 28,
907 BPB_TotSec32 = 32
908 };
909
914 yconstexpr const size_t MinSectorSize(512), MaxSectorSize(4096);
916
918 inline namespace FAT16
919 {
920
925 enum BPB : size_t
926 {
927 BS_DrvNum = 36,
928 BS_Reserved1 = 37,
929 BS_BootSig = 38,
930 BS_VolID = 39,
931 BS_VolLab = 43,
932 BS_FilSysType = 54,
933 _reserved_zero_448 = 62,
934 Signature_word = 510,
935 _reserved_remained = 512
936 };
937
938 } // inline namespace FAT16;
939
941 inline namespace FAT32
942 {
943
948 enum BPB : size_t
949 {
950 BPB_FATSz32 = 36,
951 BPB_ExtFlags = 40,
952 BPB_FSVer = 42,
953 BPB_RootClus = 44,
954 BPB_FSInfo = 48,
955 BPB_BkBootSec = 50,
956 BPB_Reserved = 52,
957 BS_DrvNum = 64,
958 BS_Reserved1 = 65,
959 BS_BootSig = 66,
960 BS_VolID = 67,
961 BS_VolLab = 71,
962 BS_FilSysType = 82,
963 _reserved_zero_420 = 90
964 };
965
966 } // inline namespace FAT32;
967
973 yconstexpr const char FATSignature[]{'F', 'A', 'T'};
975
977 YB_ATTR_nodiscard YB_NONNULL(1) YB_PURE inline
978 PDefH(bool, MatchFATSignature, const void* p)
979 ImplRet(std::memcmp(p, FATSignature, sizeof(FATSignature)) == 0)
980
987 YB_ATTR_nodiscard YB_NONNULL(1) YB_PURE bool
988 CheckValidMBR(const byte*);
990
996 using VolumeLabel = array<byte, 11>;
997
999
1000 enum FSI : size_t
1002 {
1003 FSI_LeadSig = 0,
1004 FSI_Reserved1 = 4,
1005 FSI_StrucSig = 484,
1006 FSI_Free_Count = 488,
1007 FSI_Nxt_Free = 492,
1008 FSI_Reserved2 = 496,
1009 FSI_TrailSig = 508
1010 };
1011
1012 yconstexpr const std::uint32_t FSI_LeadSig_Value(0x41615252),
1013 FSI_StrucSig_Value(0x61417272), FSI_TrailSig_Value(0xAA550000);
1015
1016
1021 enum class Attribute : octet
1022 {
1023 ReadOnly = 0x01,
1024 Hidden = 0x02,
1025 System = 0x04,
1026 VolumeID = 0x08,
1027 Directory = 0x10,
1028 Archive = 0x20,
1029 LongFileName = ReadOnly | Hidden | System | VolumeID
1030 };
1031
1033 DefBitmaskEnum(Attribute)
1034
1035
1036 namespace Clusters
1038 {
1039
1040 // !\see Microsoft FAT Specification Section 3.2 。
1042 yconstexpr const size_t PerFAT12(4085);
1043 yconstexpr const size_t PerFAT16(65525);
1045
1046 enum : ClusterIndex
1047 {
1048 FAT16RootDirectory = 0,
1054 MaxValid12 = 0xFF6,
1055 MaxValid16 = 0xFFF6,
1056 MaxValid32 = 0xFFFFFF6,
1057 Bad12 = 0xFF7,
1058 Bad16 = 0xFFF7,
1059 Bad32 = 0xFFFFFF7,
1060 EndOfFile12 = 0xFFF,
1061 EndOfFile16 = 0xFFFF,
1062 EndOfFile32 = 0xFFFFFFFF,
1064 EndOfFile = 0x0FFFFFFF,
1065 First = 0x00000002,
1066 Root = 0x00000000,
1067 Free = 0x00000000,
1068 Error = 0xFFFFFFFF
1069 };
1070
1072 inline PDefH(bool, IsFreeOrEOF, ClusterIndex c) ynothrow
1073 ImplRet(c == Clusters::Free || c == Clusters::EndOfFile)
1074
1075
1080 static yconstexpr const ClusterCount UnknownFreeCount(0xFFFFFFFF);
1081
1082 } // namespace Clusters;
1083
1084
1086 const char IllegalAliasCharacters[]{"\\/:;*?\"<>|&+,=[] "};
1087
1088
1090 using FileSize = std::uint32_t;
1091
1096 static yconstexpr const auto MaxFileSize(FileSize(0xFFFFFFFF));
1097
1098
1100 using Timestamp = std::uint16_t;
1101
1103 YB_ATTR_nodiscard YF_API std::time_t
1104 ConvertFileTime(Timestamp, Timestamp) ynothrow;
1105
1107 YB_ATTR_nodiscard YF_API pair<Timestamp, Timestamp>
1108 FetchDateTime() ynothrow;
1109
1110
1116 namespace LFN
1117 {
1118
1120 enum Offsets
1121 {
1123 Ordinal = 0x00,
1124 Char0 = 0x01,
1125 Char1 = 0x03,
1126 Char2 = 0x05,
1127 Char3 = 0x07,
1128 Char4 = 0x09,
1130 Flag = 0x0B,
1132 Reserved1 = 0x0C,
1134 CheckSum = 0x0D,
1135 Char5 = 0x0E,
1136 Char6 = 0x10,
1137 Char7 = 0x12,
1138 Char8 = 0x14,
1139 Char9 = 0x16,
1140 Char10 = 0x18,
1142 Reserved2 = 0x1A,
1143 Char11 = 0x1C,
1144 Char12 = 0x1E
1145 };
1146
1148 yconstexpr const size_t OffsetTable[]{0x01, 0x03, 0x05, 0x07, 0x09, 0x0E,
1149 0x10, 0x12, 0x14, 0x16, 0x18, 0x1C, 0x1E};
1150
1151 enum : size_t
1152 {
1154 #if YCL_DS
1155 MaxLength = 255,
1156 #else
1157 MaxLength = 256,
1158 #endif
1159 #if YCL_DS
1161 MaxMBCSLength = 255,
1162 #else
1163 MaxMBCSLength = MaxLength * 3,
1164 #endif
1165 EntryLength = size(OffsetTable),
1166 AliasEntryLength = 11,
1167 MaxAliasMainPartLength = 8,
1168 MaxAliasExtensionLength = 3,
1169 MaxAliasLength = MaxAliasMainPartLength + MaxAliasExtensionLength + 2,
1170 MaxNumericTail = 999999
1171 };
1172
1173 enum EntryValues : octet
1174 {
1176 CaseLowerBasename = 0x08,
1178 CaseLowerExtension = 0x10,
1180 LastLongEntry = 0x40
1181 };
1182
1184 const char IllegalCharacters[]{"\\/:*?\"<>|"};
1185
1187
1188
1195 YB_ATTR_nodiscard YF_API tuple<string, string, bool>
1196 ConvertToAlias(const u16string&);
1197
1199 YB_ATTR_nodiscard inline PDefH(size_t, FetchLongNameOffset, EntryDataUnit ord)
1200 ynothrow
1201 ImplRet((size_t(std::uint8_t(ord) & ~LastLongEntry) - 1U) * EntryLength)
1203
1208 YB_ATTR_nodiscard YF_API string
1209 ConvertToMBCS(const char16_t* path);
1210
1216 YB_ATTR_nodiscard YF_API YB_NONNULL(1) YB_PURE EntryDataUnit
1217 GenerateAliasChecksum(const EntryDataUnit*) ynothrowv;
1218
1224 YB_ATTR_nodiscard YF_API YB_PURE bool
1225 ValidateName(string_view) ynothrowv;
1226
1232 YF_API void
1233 WriteNumericTail(string&, size_t) ynothrowv;
1234
1235 } // namespace LFN;
1236
1238
1239 yconstexpr const size_t EntryDataSize(0x20);
1241
1246 class YF_API EntryData final : private array<EntryDataUnit, EntryDataSize>
1247 {
1248 public:
1249 using Base = array<EntryDataUnit, EntryDataSize>;
1254 enum Offsets : size_t
1255 {
1256 Name = 0x00,
1257 Extension = 0x08,
1258 Attributes = 0x0B,
1260 CaseInfo = 0x0C,
1261 CTimeTenth = 0x0D,
1262 CTime = 0x0E,
1263 CDate = 0x10,
1264 ADate = 0x12,
1265 ClusterHigh = 0x14,
1266 MTime = 0x16,
1267 MDate = 0x18,
1268 Cluster = 0x1A,
1269 FileSize = 0x1C
1270 };
1272 enum : octet
1273 {
1274 Last = 0x00,
1275 Free = 0xE5,
1276 };
1277
1278 using Base::operator[];
1279 using Base::data;
1280
1281 DefPred(const ynothrow, Directory,
1282 bool(Attribute((*this)[Attributes]) & Attribute::Directory))
1283 DefPred(const ynothrow, LongFileName,
1284 Attribute((*this)[Attributes]) == Attribute::LongFileName)
1285 DefPred(const ynothrow, Volume, bool(Attribute((*this)[Attributes])
1286 & Attribute::VolumeID))
1287 DefPred(const ynothrow, Writable,
1288 !bool(Attribute((*this)[Attributes]) & Attribute::ReadOnly))
1289
1290 PDefH(void, SetDirectoryAttribute, ) ynothrow
1291 ImplExpr((*this)[Attributes] = EntryDataUnit(Attribute::Directory))
1292 PDefH(void, SetDot, size_t n) ynothrowv
1293 ImplExpr(YAssert(n < EntryDataSize, "Invalid argument found."),
1294 (*this)[n] = EntryDataUnit('.'))
1295
1296 PDefH(void, Clear, ) ynothrow
1297 ImplExpr(ystdex::trivially_fill_n(static_cast<Base*>(this)))
1298
1299 PDefH(void, ClearAlias, ) ynothrow
1300 ImplExpr(ystdex::trivially_fill_n(data(), LFN::AliasEntryLength,
1301 EntryDataUnit(' ')))
1302
1307 void
1308 CopyLFN(char16_t*) const ynothrowv;
1309
1310 PDefH(void, FillLast, ) ynothrow
1311 ImplExpr(ystdex::trivially_fill_n(static_cast<Base*>(this), 1,
1312 EntryDataUnit(Last)))
1313
1324 pair<EntryDataUnit, size_t>
1325 FillNewName(string_view, ystdex::function<bool(string_view)>);
1326
1331 YB_ATTR_nodiscard bool
1332 FindAlias(string_view) const;
1333
1334 YB_ATTR_nodiscard string
1335 GenerateAlias() const;
1336
1337 PDefH(std::uint32_t, ReadFileSize, ) ynothrow
1338 ImplRet(ystdex::read_uint_le<32>(data() + FileSize))
1339
1340 void
1341 SetupRoot(ClusterIndex) ynothrow;
1342
1343 void
1344 WriteAlias(const string&) ynothrow;
1345
1346 void
1347 WriteCDateTime() ynothrow;
1348
1349 void
1350 WriteCluster(ClusterIndex) ynothrow;
1351
1352 void
1353 WriteDateTime() ynothrow;
1354 };
1356
1357
1365 YF_API YB_NONNULL(1) YB_PURE const char*
1366 CheckColons(const char*);
1367
1368 } // namespace FAT;
1369
1370 } // namespace platform;
1371
1372 namespace platform_ex
1373 {
1374
1375 } // namespace platform_ex;
1376
1377 #endif
1378
platform::HDirectory::DefBoolNeg
YB_PURE DefBoolNeg(YB_PURE explicit, bool(p_dirent)) YB_ATTR_nodiscard YB_PURE DefCvt(const ynothrow
判断文件系统节点无效或有效性。
platform::FAT::LFN::Reserved2
@ Reserved2
Definition: YCLib/FileSystem.h:1142
YB_ATTR_nodiscard
#define YB_ATTR_nodiscard
标记返回值不被忽略的属性。
Definition: ydef.h:715
DefPred
#define DefPred(_q, _n,...)
Definition: YBaseMacro.h:232
platform::FAT::ConvertFileTime
YB_ATTR_nodiscard YF_API std::time_t ConvertFileTime(Timestamp, Timestamp) ynothrow
转换日期和时间的时间戳为标准库时间类型。
Definition: YCLib/FileSystem.cpp:523
platform::FAT::FSI_TrailSig_Value
yconstexpr const std::uint32_t FSI_TrailSig_Value(0xAA550000)
platform::FAT::FSI_TrailSig
@ FSI_TrailSig
Definition: YCLib/FileSystem.h:1009
platform::FAT::LFN::MaxAliasLength
@ MaxAliasLength
Definition: YCLib/FileSystem.h:1169
platform::FAT::CheckColons
const char * CheckColons(const char *path)
Definition: YCLib/FileSystem.cpp:869
platform::IsDirectory
bool IsDirectory(const char *path)
Definition: YCLib/FileSystem.cpp:142
platform::FAT::MatchFATSignature
YB_ATTR_nodiscard MatchFATSignature
Definition: YCLib/FileSystem.h:978
platform::Nonnull
YB_PURE _type && Nonnull(_type &&p) ynothrowv
断言并返回非空参数。
Definition: Debug.h:518
size
size_t size
Definition: memory_resource.cpp:295
ystdex::is_trivially_replaceable
判断是否可平凡替换存储。
Definition: type_pun.hpp:94
platform::FAT::LFN::Char12
@ Char12
Definition: YCLib/FileSystem.h:1144
platform::FAT::EntryData::DefPred
DefPred(const ynothrow, Directory, bool(Attribute((*this)[Attributes]) &Attribute::Directory)) DefPred(const ynothrow
platform::FAT::LFN::Reserved1
@ Reserved1
Definition: YCLib/FileSystem.h:1132
platform::FAT::FAT16::Signature_word
@ Signature_word
Definition: YCLib/FileSystem.h:934
platform::FAT::LFN::MaxMBCSLength
@ MaxMBCSLength
UTF-8 项最大长度。
Definition: YCLib/FileSystem.h:1163
CHRLib::c
c
Definition: CharacterProcessing.h:84
platform::FAT::FAT32::BPB_FATSz32
@ BPB_FATSz32
Definition: YCLib/FileSystem.h:950
platform::FAT::LFN::Char2
@ Char2
Definition: YCLib/FileSystem.h:1126
yconstexpr
#define yconstexpr
指定编译时常量表达式。
Definition: ydef.h:1072
platform::FAT::FSI_Free_Count
@ FSI_Free_Count
Definition: YCLib/FileSystem.h:1006
base.h
基类实用设施。
YB_PURE
#define YB_PURE
指示函数或函数模板实例为纯函数。
Definition: ydef.h:919
platform::FAT::LFN::MaxAliasExtensionLength
@ MaxAliasExtensionLength
Definition: YCLib/FileSystem.h:1168
platform::references::unique_ptr_from
unique_ptr< ystdex::defer_element< ystdex::unique_ptr_pointer< void, _tDeleter >, _tDefault >, _tDeleter > unique_ptr_from
取删除器对应的 unique_ptr 实例。
Definition: Reference.h:110
ystdex::cpp2017::basic_string
Definition: string.hpp:77
platform::FAT::BPB_HiddSec
@ BPB_HiddSec
Definition: YCLib/FileSystem.h:906
platform::CreateSymbolicLink
void CreateSymbolicLink(const char *dst, const char *src, bool is_dir)
Definition: YCLib/FileSystem.cpp:199
platform_ex::Windows::VolumeID
std::uint32_t VolumeID
卷序列号。
Definition: Win32/include/YCLib/MinGW32.h:844
platform_ex
平台扩展命名空间。
Definition: Android.h:46
ystdex::cpp2014::min
const _type & min(const _type &a, const _type &b, _fComp comp=less< _type >())
取较小的元素。
Definition: algorithm.hpp:614
platform::FAT::LFN::GenerateAliasChecksum
EntryDataUnit GenerateAliasChecksum(const EntryDataUnit *p) ynothrowv
Definition: YCLib/FileSystem.cpp:635
platform::FAT::BPB_TotSec32
@ BPB_TotSec32
Definition: YCLib/FileSystem.h:907
ystdex::cpp2017::basic_string_view
Definition: string_view.hpp:95
platform::FAT::LFN::MaxAliasMainPartLength
@ MaxAliasMainPartLength
Definition: YCLib/FileSystem.h:1167
platform::FAT::LFN::ValidateName
YB_ATTR_nodiscard YF_API YB_PURE bool ValidateName(string_view) ynothrowv
检查名称是否为合法的可被 UCS-2 表示的非控制字符组成。
Definition: YCLib/FileSystem.cpp:650
platform::FAT::LFN::IllegalCharacters
const char IllegalCharacters[]
非法长文件名字符。
Definition: YCLib/FileSystem.h:1184
platform::FAT::BPB_RootEntCnt
@ BPB_RootEntCnt
Definition: YCLib/FileSystem.h:900
ystdex::cpp2017::string_view
basic_string_view< char > string_view
Definition: string_view.hpp:437
platform::DirectorySession::DirectorySession
DirectorySession()
构造：打开目录路径。
Definition: YCLib/FileSystem.cpp:352
platform::FAT::FAT32::_reserved_zero_420
@ _reserved_zero_420
Definition: YCLib/FileSystem.h:963
platform::FAT::EntryData
目录项数据。
Definition: YCLib/FileSystem.h:1247
platform::FAT::FSI_LeadSig
@ FSI_LeadSig
Definition: YCLib/FileSystem.h:1003
DefDeMoveCtor
#define DefDeMoveCtor(_t)
Definition: YBaseMacro.h:167
platform::IsSeparator_P
YB_STATELESS YCL_Tag_constfn bool IsSeparator_P(IDTag< YF_Platform_Win32 > tag, _tChar c) ynothrow
Definition: YCLib/FileSystem.h:103
platform::FAT::FAT32::BPB_RootClus
@ BPB_RootClus
Definition: YCLib/FileSystem.h:953
platform::DirectorySession::YB_NONNULL
YB_NONNULL(2) DirectorySession(const char *)
platform::FAT::CheckValidMBR
bool CheckValidMBR(const byte *sec_buf)
Definition: YCLib/FileSystem.cpp:513
platform::path
_tString && path
Definition: YCLib/FileSystem.h:464
platform::size_t
YB_ATTR_nodiscard YF_API size_t
Definition: FileIO.h:1345
ystdex::trivially_fill_n
_type * trivially_fill_n(_type *first, size_t n=1, byte value={})
填充字节序列。
Definition: algorithm.hpp:444
platform::FAT::LFN::CaseLowerBasename
@ CaseLowerBasename
WinNT 小写文件名。
Definition: YCLib/FileSystem.h:1176
platform::FAT::FATSignature
yconstexpr const char FATSignature[]
FAT 签名：扩展 BPB 中的 BS_FilSysType 公共前缀。
Definition: YCLib/FileSystem.h:974
platform::IsAbsolute_P
YB_ATTR_nodiscard YB_PURE bool IsAbsolute_P(IDTag< YF_Platform_DS > tag, basic_string_view< _tChar > path) ynothrowv
Definition: YCLib/FileSystem.h:144
platform::FAT::FileSize
std::uint32_t FileSize
文件大小：字节数。
Definition: YCLib/FileSystem.h:1090
platform::FetchRootNameLength_P
YB_ATTR_nodiscard YB_PURE size_t FetchRootNameLength_P(IDTag< YF_Platform_DS >, basic_string_view< _tChar > path) ynothrowv
Definition: YCLib/FileSystem.h:238
platform::DirectorySession::sDirPath
string sDirPath
目录路径。
Definition: YCLib/FileSystem.h:684
platform::FAT::EntryData::Base
array< EntryDataUnit, EntryDataSize > Base
Definition: YCLib/FileSystem.h:1249
platform::if
if(!p) p
platform::FAT::Attribute
Attribute
文件属性。
Definition: YCLib/FileSystem.h:1022
platform::FAT::MinSectorSize
yconstexpr const size_t MinSectorSize(512)
BIOS 参数块偏移量域 BPB_BytsPerSec 的最值。
platform::DirectorySession
目录会话：表示打开的目录。
Definition: YCLib/FileSystem.h:650
platform::FAT::FSI_Reserved1
@ FSI_Reserved1
Definition: YCLib/FileSystem.h:1004
YF_API
#define YF_API
Definition: Platform.h:56
platform::IDTag< YF_Platform_Win32 >
Definition: YCommon.h:93
platform::FAT::FSI_LeadSig_Value
yconstexpr const std::uint32_t FSI_LeadSig_Value(0x41615252)
ystdex::read_uint_le
make_width_int< _vWidth >::unsigned_type read_uint_le(const byte *buf)
从字节缓冲区读取指定宽的小端序无符号整数。
Definition: cstdint.hpp:528
platform::FAT::LFN::Char11
@ Char11
Definition: YCLib/FileSystem.h:1143
platform::FAT::FSI_StrucSig_Value
yconstexpr const std::uint32_t FSI_StrucSig_Value(0x61417272)
platform::FAT::LFN::WriteNumericTail
YF_API void WriteNumericTail(string &, size_t) ynothrowv
在指定字符串写前缀字符 '~' 和整数的后缀以作为短文件名。
Definition: YCLib/FileSystem.cpp:661
platform::CreateHardLink
void CreateHardLink(const char *dst, const char *src)
Definition: YCLib/FileSystem.cpp:168
platform_ex::Windows::Hidden
@ Hidden
Definition: Win32/include/YCLib/MinGW32.h:464
platform_ex::Windows::Invalid
@ Invalid
Definition: Win32/include/YCLib/MinGW32.h:485
ystdex::indirect_input_iterator
间接输入迭代器。
Definition: iterator.hpp:791
platform::FAT::FSI_StrucSig
@ FSI_StrucSig
Definition: YCLib/FileSystem.h:1005
platform::FAT::FAT32::BS_VolID
@ BS_VolID
Definition: YCLib/FileSystem.h:960
platform::YCL_DefPlatformFwdTmpl
YCL_DefPlatformFwdTmpl(IsSeparator, IsSeparator_P) template< typename _tChar > YB_ATTR_nodiscard YB_PURE YB_NONNULL(2) inline bool IsAbsolute_P(IDTag< YF_Platform_DS > tag
判断指定路径字符串是否表示一个绝对路径。
platform::DirectorySession::Deleter::pointer
NativeHandle pointer
Definition: YCLib/FileSystem.h:669
YAssert
#define YAssert(_expr, _msg)
Definition: cassert.h:154
platform::FAT::LFN::CaseLowerExtension
@ CaseLowerExtension
WinNT 小写扩展名。
Definition: YCLib/FileSystem.h:1178
platform::FAT::FAT32::BS_Reserved1
@ BS_Reserved1
Definition: YCLib/FileSystem.h:958
platform::FAT::LFN::AliasEntryLength
@ AliasEntryLength
Definition: YCLib/FileSystem.h:1166
YF_Platform_Win32
#define YF_Platform_Win32
Win32 平台。
Definition: Platform.h:136
platform::ReadLink
string ReadLink(const char *path)
Definition: YCLib/FileSystem.cpp:230
ystdex::deref_self
bases::deref_self< _type > deref_self
Definition: base.h:222
platform::FAT::Timestamp
std::uint16_t Timestamp
时间戳：表示日期和时间的整数类型。
Definition: YCLib/FileSystem.h:1100
platform::FAT::FAT32::BS_FilSysType
@ BS_FilSysType
Definition: YCLib/FileSystem.h:962
platform::FAT::EntryData::Offsets
Offsets
目录项偏移量。
Definition: YCLib/FileSystem.h:1255
platform::FAT::LFN::OffsetTable
yconstexpr const size_t OffsetTable[]
组成长文件名中的 UCS-2 字符在项中的偏移量表。
Definition: YCLib/FileSystem.h:1148
platform::FAT::FAT32::BPB_BkBootSec
@ BPB_BkBootSec
Definition: YCLib/FileSystem.h:955
platform::FAT::LFN::MaxNumericTail
@ MaxNumericTail
Definition: YCLib/FileSystem.h:1170
ystdex::is_null
bool is_null(_tChar c)
使用 std::char_traits::eq 判断是否为空字符。
Definition: cstring.h:127
YB_ATTR_returns_nonnull
#define YB_ATTR_returns_nonnull
指示返回非空属性。
Definition: ydef.h:761
DefBoolNeg
#define DefBoolNeg(_spec,...)
定义表示显式转换 bool 操作符及其否定的 operator! 。
Definition: YBaseMacro.h:228
DefDeDtor
#define DefDeDtor(_t)
Definition: YBaseMacro.h:177
platform::IsColon
YB_ATTR_nodiscard YB_STATELESS yconstfn bool IsColon(_tChar c) ynothrow
Definition: YCLib/FileSystem.h:62
function.hpp
函数基本操作和调用包装对象。
platform::FAT::LFN::CheckSum
@ CheckSum
短文件名（别名）校验和。
Definition: YCLib/FileSystem.h:1134
platform::FAT::FSI_Reserved2
@ FSI_Reserved2
Definition: YCLib/FileSystem.h:1008
platform::ImplRet
YB_ATTR_nodiscard const char *s ImplRet(Nonnull(s)) YB_ATTR_nodiscard inline PDefH(const string &
platform::FetchRootPathLength_P
YB_ATTR_nodiscard YB_PURE size_t FetchRootPathLength_P(IDTag< YF_Platform_DS >, basic_string_view< _tChar > path) ynothrowv
Definition: YCLib/FileSystem.h:375
YSLib::IO::_tString
const string &path const String &path class class class _tString
Definition: YSLib/Service/FileSystem.h:612
platform::FAT::LFN::EntryLength
@ EntryLength
Definition: YCLib/FileSystem.h:1165
YB_NORETURN
#define YB_NORETURN
指定无返回值函数。
Definition: ydef.h:877
YF_Platform_DS
#define YF_Platform_DS
目标平台标识。
Definition: Platform.h:130
yforward
#define yforward(_expr)
根据参数类型使用 std::forward 转发对应参数。
Definition: ydef.h:1508
platform::ynothrow
const _tString &path ynothrow
Definition: YCLib/FileSystem.h:453
platform::FAT::BPB_Media
@ BPB_Media
Definition: YCLib/FileSystem.h:902
ystdex::string_traits::const_pointer
const value_type * const_pointer
Definition: string.hpp:802
ystdex::cpp2017::data
auto data(_tRange &c) -> decltype(c.data())
Definition: range.hpp:581
platform::FAT::LFN::Char3
@ Char3
Definition: YCLib/FileSystem.h:1127
platform::FAT::BPB_TotSec16
@ BPB_TotSec16
Definition: YCLib/FileSystem.h:901
YB_STATELESS
#define YB_STATELESS
指示函数或函数模板实例为无状态函数。
Definition: ydef.h:941
ystdex::cpp2017::end
auto end(_tRange &c) -> decltype(c.end())
Definition: range.hpp:345
platform::FetchRootNameEnd_P
YB_ATTR_nodiscard YB_PURE basic_string_view< _tChar >::const_iterator FetchRootNameEnd_P(_tTag, basic_string_view< _tChar >) ynothrowv
Definition: YCLib/FileSystem.h:345
platform::FAT::EntryDataUnit
byte EntryDataUnit
Definition: YCLib/FileSystem.h:878
ystdex::rtrim
_tString && rtrim(_tString &&str, typename string_traits< _tString >::value_type c)
删除字符串中指定的连续后缀字符。
Definition: string.hpp:1454
std
Definition: optional.h:982
iterator.hpp
通用迭代器。
platform::FAT::FAT32::BS_BootSig
@ BS_BootSig
Definition: YCLib/FileSystem.h:959
YAssertNonnull
#define YAssertNonnull(_expr)
Definition: cassert.h:165
platform::FAT::Attribute::LongFileName
@ LongFileName
NPL::ReductionStatus::Regular
@ Regular
已取得正规表示的规约：规约成功且已保证正规化，不指定是否需要保留子项。
platform::FAT::LFN::MaxLength
@ MaxLength
UCS-2 项最大长度。
Definition: YCLib/FileSystem.h:1157
platform::FAT::LFN::Char5
@ Char5
Definition: YCLib/FileSystem.h:1135
ystdex::to_array
std::array< _type, _vN > to_array(const _tSrc &src)
转换指定参数为 std::array 对象。
Definition: array.hpp:92
platform::FAT::LFN::LastLongEntry
@ LastLongEntry
Ordinal 中标记结束的项。
Definition: YCLib/FileSystem.h:1180
YSLib::i
return i
Definition: YCoreUtilities.h:177
YSLib::Drawing::ImageFormat::Unknown
@ Unknown
platform::FAT::FAT32::BPB_Reserved
@ BPB_Reserved
Definition: YCLib/FileSystem.h:956
platform::FAT::ClusterIndex
std::uint32_t ClusterIndex
Definition: YCLib/FileSystem.h:879
platform::FAT::LFN::ConvertToMBCS
string ConvertToMBCS(const char16_t *path)
Definition: YCLib/FileSystem.cpp:627
platform_ex::Windows::Directory
@ Directory
Definition: Win32/include/YCLib/MinGW32.h:466
platform::FAT::BS_jmpBoot
@ BS_jmpBoot
Definition: YCLib/FileSystem.h:894
platform::YB_NONNULL
YB_NONNULL(2) YB_PURE inline PDefH(std
组合消息和函数签名字符串。
Definition: Debug.h:560
platform::HDirectory
目录句柄：表示打开的目录和内容迭代状态。
Definition: YCLib/FileSystem.h:745
platform::FAT::LFN::Char9
@ Char9
Definition: YCLib/FileSystem.h:1139
platform::FAT::FAT32::BPB
BPB
FAT32 扩展 BIOS 参数块偏移量。
Definition: YCLib/FileSystem.h:949
platform
默认平台命名空间。
Definition: Container.h:56
platform::IDTagBase
平台标识的公共标记类型：指定任意平台。
Definition: YCommon.h:62
platform::FAT::IllegalAliasCharacters
const char IllegalAliasCharacters[]
非法别名字符。
Definition: YCLib/FileSystem.h:1086
platform::FAT::EntryDataSize
yconstexpr const size_t EntryDataSize(0x20)
目录项数据大小。
platform::FAT::LFN::Flag
@ Flag
Definition: YCLib/FileSystem.h:1130
YModules.h
YSLib 用户界面模块配置文件。
platform::FAT::FSI
FSI
文件系统信息块偏移量。
Definition: YCLib/FileSystem.h:1002
platform::FAT::BPB_RsvdSecCnt
@ BPB_RsvdSecCnt
Definition: YCLib/FileSystem.h:898
platform::FAT::LFN::EntryValues
EntryValues
Definition: YCLib/FileSystem.h:1174
ystdex::is_undereferenceable
bool is_undereferenceable(const _tIter &)
Definition: deref_op.hpp:46
platform::DirectorySession::dir
unique_ptr_from< Deleter > dir
Definition: YCLib/FileSystem.h:689
platform::HDirectory::NativeChar
char NativeChar
Definition: YCLib/FileSystem.h:757
type_pun.hpp
共享存储和直接转换。
platform::FetchSeparator_P
YB_STATELESS YCL_Tag_constfn _tChar FetchSeparator_P(IDTag< YF_Platform_Win32 >) ynothrow
Definition: YCLib/FileSystem.h:80
platform::Deref
YB_PURE yconstfn auto Deref(_type &&p) -> decltype(*p)
断言并解引用非空指针。
Definition: Debug.h:547
platform::FAT::FAT32::BPB_ExtFlags
@ BPB_ExtFlags
Definition: YCLib/FileSystem.h:951
platform::FAT::BPB_SecPerTrk
@ BPB_SecPerTrk
Definition: YCLib/FileSystem.h:904
platform_ex::Windows::ReadOnly
@ ReadOnly
Definition: Win32/include/YCLib/MinGW32.h:463
platform::tail
_tString ystdex::string_traits< _tString >::const_pointer tail
Definition: YCLib/FileSystem.h:465
platform::FAT::LFN::Char8
@ Char8
Definition: YCLib/FileSystem.h:1138
CHRLib::char16_t
YB_ATTR_nodiscard YB_PURE char16_t((*c_ptr<< CHAR_BIT)|c_ptr[1])) YB_ATTR_nodiscard YB_PURE inline PDefH(char16_t
取 c_ptr 指向的小端序双字节字符。
YCL_Tag_constfn
#define YCL_Tag_constfn
包含平台标签的常量表达式函数。
Definition: YCommon.h:114
platform::DirectorySession::Data
void Data
Definition: YCLib/FileSystem.h:657
platform::FAT::ClusterCount
std::uint32_t ClusterCount
Definition: YCLib/FileSystem.h:881
ystdex
<memory> 特性测试宏。
Definition: ydef.h:1262
platform::IDTag
平台标识的整数标记类型。
Definition: YCommon.h:76
platform::FAT::FetchDateTime
YB_ATTR_nodiscard YF_API pair< Timestamp, Timestamp > FetchDateTime() ynothrow
取以实时时钟的文件日期和时间。
Definition: YCLib/FileSystem.cpp:540
YSLib::IO::IsAbsolute
IsAbsolute
Definition: YSLib/Service/FileSystem.h:62
platform::FAT::LFN::Ordinal
@ Ordinal
长文件名序数。
Definition: YCLib/FileSystem.h:1123
ystdex::string_traits::value_type
remove_cvref_t< decltype(std::declval< string_type >()[0])> value_type
Definition: string.hpp:790
platform::FAT::LFN::Offsets
Offsets
长文件名目录项偏移量。
Definition: YCLib/FileSystem.h:1121
platform::FAT::LFN::ConvertToAlias
YB_ATTR_nodiscard YF_API tuple< string, string, bool > ConvertToAlias(const u16string &)
转换长文件名为别名。
Definition: YCLib/FileSystem.cpp:568
platform::FAT::LFN::Char0
@ Char0
Definition: YCLib/FileSystem.h:1124
platform::FAT::FSI_Nxt_Free
@ FSI_Nxt_Free
Definition: YCLib/FileSystem.h:1007
YCL_Impl_DefPlatformStringFwdTmpl
#define YCL_Impl_DefPlatformStringFwdTmpl(_fn)
platform::KeyCodes::Win32::Empty
@ Empty
Definition: Keys.h:282
ystdex::octet
void octet
Definition: ydef.h:1294
platform::FetchSeparator
YB_STATELESS yconstfn _tChar FetchSeparator() ynothrow
Definition: YCLib/FileSystem.h:93
ystdex::bases::deref_self
间接操作：返回派生类自身引用。
Definition: base.h:153
DefCvt
#define DefCvt(_q, _t,...)
Definition: YBaseMacro.h:206
platform::FAT::FAT16::_reserved_remained
@ _reserved_remained
Definition: YCLib/FileSystem.h:935
platform::FAT::LFN::Char6
@ Char6
Definition: YCLib/FileSystem.h:1136
platform::FAT::LFN::Char4
@ Char4
Definition: YCLib/FileSystem.h:1128
ImplExpr
#define ImplExpr(...)
简单通用函数实现。
Definition: YBaseMacro.h:96
platform::FAT::FAT32::BS_VolLab
@ BS_VolLab
Definition: YCLib/FileSystem.h:961
platform::PDefH
YB_ATTR_nodiscard PDefH(string, MakePathString, u16string_view sv) ImplRet(MakePathString(sv.data())) using FileNodeID
文件节点标识类型。
DefGetter
#define DefGetter(_q, _t, _n,...)
Definition: YBaseMacro.h:241
ystdex::ntctschr
_tChar * ntctschr(_tChar *s, remove_const_t< _tChar > c)
在简单 NTCTS 内查找字符。
Definition: cstring.h:393
platform::KeyCategory::Character
@ Character
表示产生字符的键。
Definition: Keys.h:111
DefBitmaskEnum
#define DefBitmaskEnum(_tEnum)
Definition: YBaseMacro.h:505
platform::FAT::FAT16::_reserved_zero_448
@ _reserved_zero_448
Definition: YCLib/FileSystem.h:933
platform::DirectorySession::Deleter
Definition: YCLib/FileSystem.h:667
platform::FAT::VolumeLabel
array< byte, 11 > VolumeLabel
卷标数据类型。
Definition: YCLib/FileSystem.h:996
platform::FAT::BPB_SecPerClus
@ BPB_SecPerClus
Definition: YCLib/FileSystem.h:897
platform_ex::Windows::Archive
@ Archive
Definition: Win32/include/YCLib/MinGW32.h:467
platform::FAT::FAT32::BPB_FSVer
@ BPB_FSVer
Definition: YCLib/FileSystem.h:952
platform::FAT::MaxSectorSize
yconstexpr const size_t MaxSectorSize(4096)
platform::ynothrowv
YB_ATTR_nodiscard YF_API int amode ynothrowv
Definition: FileIO.h:550
ystdex::byte
unsigned char byte
字节类型。
Definition: ydef.h:1283
platform::FAT::LFN::Char7
@ Char7
Definition: YCLib/FileSystem.h:1137
platform::FAT::BPB_BytsPerSec
@ BPB_BytsPerSec
Definition: YCLib/FileSystem.h:896
platform::p
return p p
Definition: YCLib/FileSystem.h:209
platform::FAT::MaxFileSize
static yconstexpr const auto MaxFileSize(FileSize(0xFFFFFFFF))
最大文件大小。
ystdex::function
function_base< function_traits< _fSig, empty_function_policy::throwing >, _fSig > function
函数包装类模板。
Definition: function.hpp:900
platform::FAT::FAT32::BPB_FSInfo
@ BPB_FSInfo
Definition: YCLib/FileSystem.h:954
const
const Decapsulate const Decapsulate &y ynothrow ContextNode &ctx const
Definition: NPLA1Forms.cpp:1629
platform::bool
YB_ATTR_nodiscard std::FILE *fp bool
Definition: FileIO.h:1271
DefDeMoveAssignment
#define DefDeMoveAssignment(_t)
Definition: YBaseMacro.h:191
platform::strings::u16string
basic_string< char16_t > u16string
Definition: Container.h:180
platform::FAT::FAT32::BS_DrvNum
@ BS_DrvNum
Definition: YCLib/FileSystem.h:957
platform_ex::Windows::Device
@ Device
Definition: Win32/include/YCLib/MinGW32.h:468
platform::FAT::LFN::Char10
@ Char10
Definition: YCLib/FileSystem.h:1140
platform::FAT::BPB_FATSz16
@ BPB_FATSz16
Definition: YCLib/FileSystem.h:903
platform::FAT::BS_OEMName
@ BS_OEMName
Definition: YCLib/FileSystem.h:895
platform::DirectorySession::NativeHandle
Data * NativeHandle
Definition: YCLib/FileSystem.h:659
platform::IterateLink
YF_API bool IterateLink(string &, size_t &)
迭代访问链接：替换非空路径并按需减少允许链接计数。
Definition: YCLib/FileSystem.cpp:310
platform::FAT::LFN::Char1
@ Char1
Definition: YCLib/FileSystem.h:1125
NPL::get
PDefH(void, LiftTermRef, TermNode &term, const TermNode &tm) ImplExpr(NPL ref get()
Definition: NPLA.h:1737
platform::FAT::BPB_NumHeads
@ BPB_NumHeads
Definition: YCLib/FileSystem.h:905
yconstfn
#define yconstfn
指定编译时常量函数。
Definition: ydef.h:1073
ystdex::cpp2017::begin
auto begin(_tRange &c) -> decltype(c.begin())
Definition: range.hpp:323
platform::FAT::BPB_NumFATs
@ BPB_NumFATs
Definition: YCLib/FileSystem.h:899
platform::l
return l
Definition: YCLib/FileSystem.h:402
platform::strings::string
basic_string< char > string
Definition: Container.h:178
cstdint.hpp
ISO C 标准整数类型和相关扩展操作。