YSTest: MinGW32.h 源文件

YSTest PreAlpha_b800_20170810 The YSLib Test Project

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

- 文件列表
- 文件成员

MinGW32.h
浏览该文件的文档.
1 /*
2 © 2013-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
29 #ifndef YCL_MinGW32_INC_MinGW32_h_
30 #define YCL_MinGW32_INC_MinGW32_h_ 1
31
32 #include "YCLib/YModules.h"
33 #include YFM_YCLib_Host // for string, wstring, unique_ptr_from,
34 // ystdex::ends_with, ystdex::aligned_storage_t, ystdex::pun_ref, pair;
35 #include YFM_YCLib_NativeAPI // for ERROR_SUCCESS,
36 // MAXIMUM_REPARSE_DATA_BUFFER_SIZE, MAX_PATH;
37 #if !YCL_Win32
38 # error "This file is only for Win32."
39 #endif
40 #include YFM_YCLib_Debug // for platform::Deref;
41 #include <ystdex/enum.hpp> // for ystdex::enum_union,
42 // ystdex::wrapped_enum_traits_t;
43 #include YFM_YCLib_FileIO // for platform::NodeCategory;
44 #include <chrono> // for std::chrono::nanoseconds;
45
46 namespace platform_ex
47 {
48
53 inline namespace Windows
54 {
55
57 using ErrorCode = unsigned long;
58
64 YF_API YB_STATELESS int
65 ConvertToErrno(ErrorCode) ynothrow;
66
71 inline PDefH(int, GetErrnoFromWin32, ) ynothrow
72 ImplRet(ConvertToErrno(::GetLastError()))
73
74
80 class YF_API Win32Exception : public Exception
81 {
82 public:
89 Win32Exception(ErrorCode, string_view = "Win32 exception",
90 YSLib::RecordLevel = YSLib::Emergent);
95 YB_NONNULL(4)
96 Win32Exception(ErrorCode, string_view, const char*,
97 YSLib::RecordLevel = YSLib::Emergent);
99 DefDeCopyCtor(Win32Exception)
105 ~Win32Exception() override;
106
107 DefGetter(const ynothrow, ErrorCode, ErrorCode, ErrorCode(code().value()))
109 DefGetter(const ynothrow, std::string, Message,
110 FormatMessage(GetErrorCode()))
111
112 explicit DefCvt(const ynothrow, ErrorCode, GetErrorCode())
113
114
119 static const std::error_category&
120 GetErrorCategory();
121
126 static std::string
127 FormatMessage(ErrorCode) ynothrow;
129 };
130
131
133
134
138 # define YCL_Raise_Win32E(...) \
139 do \
140 { \
141 const auto err_(::GetLastError()); \
142 \
143 throw platform_ex::Windows::Win32Exception(err_, __VA_ARGS__); \
144 }while(false)
145
147 # define YCL_RaiseZ_Win32E(_expr, ...) \
148 do \
149 { \
150 const auto err_(Windows::ErrorCode(_expr)); \
151 \
152 if(err_ != ERROR_SUCCESS) \
153 throw platform_ex::Windows::Win32Exception(err_, __VA_ARGS__); \
154 }while(false)
155
157 # define YCL_Trace_Win32E(_lv, _fn, _sig) \
158 do \
159 { \
160 const auto err_(::GetLastError()); \
161 \
162 YTraceDe(_lv, "Failed calling " #_fn " @ %s with error %lu: %s", \
163 _sig, err_, \
164 platform_ex::Win32Exception::FormatMessage(err_).c_str()); \
165 }while(false)
166
177 # define YCL_WrapCall_Win32(_fn, ...) \
178 [&](const char* sig_) YB_NONNULL(1){ \
179 const auto res_(_fn(__VA_ARGS__)); \
180 \
181 if(YB_UNLIKELY(!res_)) \
182 YCL_Raise_Win32E(#_fn, sig_); \
183 return res_; \
184 }
185
186 # define YCL_Call_Win32(_fn, _sig, ...) \
187 YCL_WrapCall_Win32(_fn, __VA_ARGS__)(_sig)
188
190 # define YCL_CallF_Win32(_fn, ...) YCL_Call_Win32(_fn, yfsig, __VA_ARGS__)
191
192
199 # define YCL_TraceWrapCall_Win32(_fn, ...) \
200 [&](const char* sig_) YB_NONNULL(1){ \
201 const auto res_(_fn(__VA_ARGS__)); \
202 \
203 if(YB_UNLIKELY(!res_)) \
204 YCL_Trace_Win32E(platform::Descriptions::Warning, _fn, sig_); \
205 return res_; \
206 }
207
208 # define YCL_TraceCall_Win32(_fn, _sig, ...) \
209 YCL_TraceWrapCall_Win32(_fn, __VA_ARGS__)(_sig)
210
211 # define YCL_TraceCallF_Win32(_fn, ...) \
212 YCL_TraceCall_Win32(_fn, yfsig, __VA_ARGS__)
213
214
215
216
217
219
220 using ModuleProc
222 = ystdex::remove_reference_t<decltype(*::GetProcAddress(::HMODULE(), {}))>;
223
229 YF_API YB_ATTR_returns_nonnull YB_NONNULL(2) ModuleProc*
230 LoadProc(::HMODULE, const char*);
231 template<typename _func>
232 inline YB_NONNULL(2) _func&
233 LoadProc(::HMODULE h_module, const char* proc)
234 {
235 return platform::Deref(reinterpret_cast<_func*>(LoadProc(h_module, proc)));
236 }
237 template<typename _func>
238 YB_NONNULL(1, 2) _func&
239 LoadProc(const wchar_t* module, const char* proc)
240 {
241 return LoadProc<_func>(YCL_CallF_Win32(GetModuleHandleW, module), proc);
242 }
244
245
246 #define YCL_Impl_W32Call_Fn(_fn) W32_##_fn##_t
247 #define YCL_Impl_W32Call_FnCall(_fn) W32_##_fn##_call
248
254 #define YCL_DeclW32Call(_fn, _module, _tRet, ...) \
255 YCL_DeclCheck_t(_fn, _fn) \
256 using YCL_Impl_W32Call_Fn(_fn) = _tRet __stdcall(__VA_ARGS__); \
257 \
258 template<typename... _tParams> \
259 auto \
260 YCL_Impl_W32Call_FnCall(_fn)(_tParams&&... args) \
261 -> YCL_CheckDecl_t(_fn)<_tParams...> \
262 { \
263 return _fn(yforward(args)...); \
264 } \
265 template<typename... _tParams> \
266 ystdex::enable_fallback_t<YCL_CheckDecl_t(_fn), \
267 YCL_Impl_W32Call_Fn(_fn), _tParams...> \
268 YCL_Impl_W32Call_FnCall(_fn)(_tParams&&... args) \
269 { \
270 return platform_ex::Windows::LoadProc<YCL_Impl_W32Call_Fn(_fn)>( \
271 L###_module, #_fn)(yforward(args)...); \
272 } \
273 \
274 template<typename... _tParams> \
275 auto \
276 _fn(_tParams&&... args) \
277 -> decltype(YCL_Impl_W32Call_FnCall(_fn)(yforward(args)...)) \
278 { \
279 return YCL_Impl_W32Call_FnCall(_fn)(yforward(args)...); \
280 }
281
282
283
288 YF_API wstring
289 FetchModuleFileName(::HMODULE = {}, YSLib::RecordLevel = YSLib::Err);
290
291
292
294
295 struct YF_API GlobalDelete
297 {
298 using pointer = ::HGLOBAL;
299
300 void
301 operator()(pointer) const ynothrow;
302 };
303
304
306 class YF_API GlobalLocked
307 {
308 private:
310 void* p_locked;
311
312 public:
318 GlobalLocked(::HGLOBAL);
319 template<typename _tPointer>
320 GlobalLocked(const _tPointer& p)
321 : GlobalLocked(p.get())
322 {}
324 ~GlobalLocked();
325
326 template<typename _type = void>
327 observer_ptr<_type>
328 GetPtr() const ynothrow
329 {
330 return make_observer(static_cast<_type*>(p_locked));
331 }
332 };
334
335
340 struct YF_API LocalDelete
341 {
342 using pointer = ::HLOCAL;
343
344 void
345 operator()(pointer) const ynothrow;
346 };
347
348
350
351
356 enum class AccessRights : ::ACCESS_MASK
357 {
358 None = 0,
359 GenericRead = GENERIC_READ,
360 GenericWrite = GENERIC_WRITE,
361 GenericReadWrite = GenericRead | GenericWrite,
362 GenericExecute = GENERIC_EXECUTE,
363 GenericAll = GENERIC_ALL,
364 MaximumAllowed = MAXIMUM_ALLOWED,
365 AccessSystemACL = ACCESS_SYSTEM_SECURITY,
366 Delete = DELETE,
367 ReadControl = READ_CONTROL,
368 Synchronize = SYNCHRONIZE,
369 WriteDAC = WRITE_DAC,
370 WriteOwner = WRITE_OWNER,
371 All = STANDARD_RIGHTS_ALL,
372 Execute = STANDARD_RIGHTS_EXECUTE,
373 StandardRead = STANDARD_RIGHTS_READ,
374 Required = STANDARD_RIGHTS_REQUIRED,
375 StandardWrite = STANDARD_RIGHTS_WRITE
376 };
377
379 DefBitmaskEnum(AccessRights)
380
381
382 enum class FileSpecificAccessRights : ::ACCESS_MASK
384 {
385 AddFile = FILE_ADD_FILE,
386 AddSubdirectory = FILE_ADD_SUBDIRECTORY,
387 AllAccess = FILE_ALL_ACCESS,
388 AppendData = FILE_APPEND_DATA,
389 CreatePipeInstance = FILE_CREATE_PIPE_INSTANCE,
390 DeleteChild = FILE_DELETE_CHILD,
391 Execute = FILE_EXECUTE,
392 ListDirectory = FILE_LIST_DIRECTORY,
393 ReadAttributes = FILE_READ_ATTRIBUTES,
394 ReadData = FILE_READ_DATA,
395 ReadEA = FILE_READ_EA,
396 Traverse = FILE_TRAVERSE,
397 WriteAttributes = FILE_WRITE_ATTRIBUTES,
398 WriteData = FILE_WRITE_DATA,
399 WriteEA = FILE_WRITE_EA,
400 Read = STANDARD_RIGHTS_READ,
401 Write = STANDARD_RIGHTS_WRITE
402 };
403
405 DefBitmaskEnum(FileSpecificAccessRights)
406
407
408 using FileAccessRights
410 = ystdex::enum_union<AccessRights, FileSpecificAccessRights>;
411
413 DefBitmaskOperations(FileAccessRights,
414 ystdex::wrapped_enum_traits_t<FileAccessRights>)
415
416
418 enum class FileShareMode : ::ACCESS_MASK
419 {
420 None = 0,
421 Delete = FILE_SHARE_DELETE,
422 Read = FILE_SHARE_READ,
423 Write = FILE_SHARE_WRITE,
424 ReadWrite = Read | Write,
425 All = Delete | Read | Write
426 };
427
429 DefBitmaskEnum(FileShareMode)
430
431
432 enum class CreationDisposition : unsigned long
434 {
435 CreateAlways = CREATE_ALWAYS,
436 CreateNew = CREATE_NEW,
437 OpenAlways = OPEN_ALWAYS,
438 OpenExisting = OPEN_EXISTING,
439 TruncateExisting = TRUNCATE_EXISTING
440 };
442
443
445
446 enum FileAttributes : unsigned long
448 {
449 ReadOnly = FILE_ATTRIBUTE_READONLY,
450 Hidden = FILE_ATTRIBUTE_HIDDEN,
451 System = FILE_ATTRIBUTE_SYSTEM,
452 Directory = FILE_ATTRIBUTE_DIRECTORY,
453 Archive = FILE_ATTRIBUTE_ARCHIVE,
454 Device = FILE_ATTRIBUTE_DEVICE,
455 Normal = FILE_ATTRIBUTE_NORMAL,
456 Temporary = FILE_ATTRIBUTE_TEMPORARY,
457 SparseFile = FILE_ATTRIBUTE_SPARSE_FILE,
458 ReparsePoint = FILE_ATTRIBUTE_REPARSE_POINT,
459 Compressed = FILE_ATTRIBUTE_COMPRESSED,
460 Offline = FILE_ATTRIBUTE_OFFLINE,
461 NotContentIndexed = FILE_ATTRIBUTE_NOT_CONTENT_INDEXED,
462 Encrypted = FILE_ATTRIBUTE_ENCRYPTED,
463 // IntegrityStream = FILE_ATTRIBUTE_INTEGRITY_STREAM,
464 IntegrityStream = 0x8000,
465 Virtual = FILE_ATTRIBUTE_VIRTUAL,
466 // NoScrubData = FILE_ATTRIBUTE_NO_SCRUB_DATA,
467 NoScrubData = 0x20000,
468 // EA = FILE_ATTRIBUTE_EA,
470 EA = 0x40000,
471 Invalid = INVALID_FILE_ATTRIBUTES
472 };
473
475 enum FileFlags : unsigned long
476 {
477 WriteThrough = FILE_FLAG_WRITE_THROUGH,
478 Overlapped = FILE_FLAG_OVERLAPPED,
479 NoBuffering = FILE_FLAG_NO_BUFFERING,
480 RandomAccess = FILE_FLAG_RANDOM_ACCESS,
481 SequentialScan = FILE_FLAG_SEQUENTIAL_SCAN,
482 DeleteOnClose = FILE_FLAG_DELETE_ON_CLOSE,
483 BackupSemantics = FILE_FLAG_BACKUP_SEMANTICS,
484 POSIXSemantics = FILE_FLAG_POSIX_SEMANTICS,
485 SessionAware = FILE_FLAG_SESSION_AWARE,
486 OpenReparsePoint = FILE_FLAG_OPEN_REPARSE_POINT,
487 OpenNoRecall = FILE_FLAG_OPEN_NO_RECALL,
488 // \see https://msdn.microsoft.com/zh-cn/library/windows/desktop/aa365150(v=vs.85).aspx 。
489 FirstPipeInstance = FILE_FLAG_FIRST_PIPE_INSTANCE
490 };
491
492 enum SecurityQoS : unsigned long
493 {
494 Anonymous = SECURITY_ANONYMOUS,
495 ContextTracking = SECURITY_CONTEXT_TRACKING,
496 Delegation = SECURITY_DELEGATION,
497 EffectiveOnly = SECURITY_EFFECTIVE_ONLY,
498 Identification = SECURITY_IDENTIFICATION,
499 Impersonation = SECURITY_IMPERSONATION,
500 Present = SECURITY_SQOS_PRESENT,
501 ValidFlags = SECURITY_VALID_SQOS_FLAGS
502 };
503
504 enum FileAttributesAndFlags : unsigned long
505 {
506 NormalWithDirectory = Normal | BackupSemantics,
507 NormalAll = NormalWithDirectory | OpenReparsePoint
508 };
510
511
516 yconstfn PDefH(bool, IsDirectory, FileAttributes attr) ynothrow
517 ImplRet(attr & Directory)
522 inline PDefH(bool, IsDirectory, const ::WIN32_FIND_DATAA& d) ynothrow
523 ImplRet(IsDirectory(FileAttributes(d.dwFileAttributes)))
528 inline PDefH(bool, IsDirectory, const ::WIN32_FIND_DATAW& d) ynothrow
529 ImplRet(IsDirectory(FileAttributes(d.dwFileAttributes)))
530
540 YF_API platform::NodeCategory
541 TryCategorizeNodeAttributes(UniqueHandle::pointer);
542
547 YF_API platform::NodeCategory
548 TryCategorizeNodeDevice(UniqueHandle::pointer);
550
558 YF_API platform::NodeCategory
560 CategorizeNode(FileAttributes, unsigned long = 0) ynothrow;
562 inline PDefH(platform::NodeCategory, CategorizeNode,
563 const ::WIN32_FIND_DATAA& d) ynothrow
564 ImplRet(CategorizeNode(FileAttributes(d.dwFileAttributes), d.dwReserved0))
569 inline PDefH(platform::NodeCategory, CategorizeNode,
570 const ::WIN32_FIND_DATAW& d) ynothrow
571 ImplRet(CategorizeNode(FileAttributes(d.dwFileAttributes), d.dwReserved0))
573
581 YF_API platform::NodeCategory
582 CategorizeNode(UniqueHandle::pointer) ynothrow;
583
584
592 YF_API YB_NONNULL(1) UniqueHandle
593 MakeFile(const wchar_t*, FileAccessRights = AccessRights::None,
594 FileShareMode = FileShareMode::All, CreationDisposition
595 = CreationDisposition::OpenExisting,
596 FileAttributesAndFlags = FileAttributesAndFlags::NormalAll) ynothrowv;
598 inline YB_NONNULL(1) PDefH(UniqueHandle, MakeFile, const wchar_t* path,
599 FileAccessRights desired_access, FileShareMode shared_mode,
600 FileAttributesAndFlags attributes_and_flags) ynothrowv
601 ImplRet(MakeFile(path, desired_access, shared_mode,
602 CreationDisposition::OpenExisting, attributes_and_flags))
603 inline YB_NONNULL(1) PDefH(UniqueHandle, MakeFile, const wchar_t* path,
604 FileAccessRights desired_access, CreationDisposition creation_disposition,
605 FileAttributesAndFlags attributes_and_flags
606 = FileAttributesAndFlags::NormalAll) ynothrowv
607 ImplRet(MakeFile(path, desired_access, FileShareMode::All,
608 creation_disposition, attributes_and_flags))
610 inline YB_NONNULL(1) PDefH(UniqueHandle, MakeFile, const wchar_t* path,
611 FileAccessRights desired_access,
612 FileAttributesAndFlags attributes_and_flags) ynothrowv
613 ImplRet(MakeFile(path, desired_access, FileShareMode::All,
614 CreationDisposition::OpenExisting, attributes_and_flags))
616
617 inline YB_NONNULL(1) PDefH(UniqueHandle, MakeFile, const wchar_t* path,
618 FileShareMode shared_mode, CreationDisposition creation_disposition
619 = CreationDisposition::OpenExisting, FileAttributesAndFlags
620 attributes_and_flags = FileAttributesAndFlags::NormalAll) ynothrowv
621 ImplRet(MakeFile(path, AccessRights::None, shared_mode,
622 creation_disposition, attributes_and_flags))
624 inline YB_NONNULL(1) PDefH(UniqueHandle, MakeFile, const wchar_t* path,
625 CreationDisposition creation_disposition, FileAttributesAndFlags
626 attributes_and_flags = FileAttributesAndFlags::NormalAll) ynothrowv
627 ImplRet(MakeFile(path, AccessRights::None, FileShareMode::All,
628 creation_disposition, attributes_and_flags))
629 inline YB_NONNULL(1) PDefH(UniqueHandle, MakeFile, const wchar_t* path,
630 FileShareMode shared_mode, FileAttributesAndFlags
631 attributes_and_flags = FileAttributesAndFlags::NormalAll) ynothrowv
632 ImplRet(MakeFile(path, AccessRights::None, shared_mode,
633 CreationDisposition::OpenExisting, attributes_and_flags))
634 inline YB_NONNULL(1) PDefH(UniqueHandle, MakeFile, const wchar_t* path,
635 FileAttributesAndFlags attributes_and_flags) ynothrowv
636 ImplRet(MakeFile(path, AccessRights::None, FileShareMode::All,
637 CreationDisposition::OpenExisting, attributes_and_flags))
639
640
641
648 YF_API bool
649 CheckWine();
650
651
657 class YF_API DirectoryFindData : private ystdex::noncopyable
658 {
659 private:
661 class YF_API Deleter
662 {
663 public:
664 using pointer = ::HANDLE;
665
666 void
667 operator()(pointer) const ynothrowv;
668 };
669
677 wstring dir_name;
679 ::WIN32_FIND_DATAW find_data;
684 unique_ptr_from<Deleter> p_node{};
685
686 public:
698 DirectoryFindData(wstring_view sv)
699 : DirectoryFindData(sv.to_string())
700 {}
702 DirectoryFindData(u16string_view sv)
703 : DirectoryFindData(wstring(sv.cbegin(), sv.cend()))
704 {}
706 DirectoryFindData(wstring);
708 DefDeDtor(DirectoryFindData)
710
711
712 DefBoolNeg(explicit, p_node.get())
713
715 DefGetter(const ynothrow, unsigned long, Attributes,
716 find_data.dwFileAttributes)
722 YB_PURE DefGetter(const ynothrow,
723 const wchar_t*, EntryName, find_data.cFileName)
724 DefGetter(const ynothrow, const ::WIN32_FIND_DATAW&, FindData, find_data)
726 DefGetter(const ynothrow, const wstring&, DirName, (YAssert(
727 dir_name.length() > 1 && ystdex::ends_with(dir_name, L"\\*"),
728 "Invalid directory name found."), dir_name))
739 platform::NodeCategory
740 GetNodeCategory() const ynothrow;
741
752 bool
753 Read();
754
756 void
757 Rewind() ynothrow;
758 };
759
760
767 class YF_API ReparsePointData
768 {
769 public:
770 struct Data;
771
772 private:
774 ystdex::aligned_storage_t<MAXIMUM_REPARSE_DATA_BUFFER_SIZE,
775 yalignof(void*)> target_buffer;
777 ystdex::pun_ref<Data> pun;
778
779 public:
780 ReparsePointData();
785 ~ReparsePointData();
786
787 DefGetter(const ynothrow, Data&, , pun.get())
788 };
789
790
800 YF_API YB_NONNULL(1) wstring
802 ResolveReparsePoint(const wchar_t*);
804 YF_API YB_NONNULL(1) wstring_view
805 ResolveReparsePoint(const wchar_t*, ReparsePointData::Data&);
807
808
815 YF_API YB_NONNULL(1) wstring
816 ExpandEnvironmentStrings(const wchar_t*);
817
818
824 using FileID = std::uint64_t;
827 using VolumeID = std::uint32_t;
829
831
832
834
836 YF_API size_t
838 QueryFileLinks(UniqueHandle::pointer);
843 YF_API YB_NONNULL(1) size_t
844 QueryFileLinks(const wchar_t*, bool = {});
846
854 YF_API pair<VolumeID, FileID>
856 QueryFileNodeID(UniqueHandle::pointer);
861 YF_API YB_NONNULL(1) pair<VolumeID, FileID>
862 QueryFileNodeID(const wchar_t*, bool = {});
864
865
872 YF_API std::uint64_t
873 QueryFileSize(UniqueHandle::pointer);
875 YF_API YB_NONNULL(1) std::uint64_t
876 QueryFileSize(const wchar_t*);
878
879 /*
880 \note 后三个参数可选，指针为空时忽略。
881 \note 最高精度取决于文件系统。
882 */
884
886
891 YF_API void
892 QueryFileTime(UniqueHandle::pointer, ::FILETIME* = {}, ::FILETIME* = {},
893 ::FILETIME* = {});
899 YF_API YB_NONNULL(1) void
900 QueryFileTime(const wchar_t*, ::FILETIME* = {}, ::FILETIME* = {},
901 ::FILETIME* = {}, bool = {});
903
913 YF_API void
914 SetFileTime(UniqueHandle::pointer, ::FILETIME* = {}, ::FILETIME* = {},
915 ::FILETIME* = {});
920 YF_API YB_NONNULL(1) void
921 SetFileTime(const wchar_t*, ::FILETIME* = {}, ::FILETIME* = {},
922 ::FILETIME* = {}, bool = {});
924
925
926
936 YF_API std::chrono::nanoseconds
937 ConvertTime(const ::FILETIME&);
942 YF_API ::FILETIME
943 ConvertTime(std::chrono::nanoseconds);
945
946
960 void
962 LockFile(UniqueHandle::pointer, std::uint64_t = 0,
963 std::uint64_t = std::uint64_t(-1), bool = true, bool = {});
964
965 bool
966 TryLockFile(UniqueHandle::pointer, std::uint64_t = 0,
967 std::uint64_t = std::uint64_t(-1), bool = true, bool = true) ynothrow;
969
974 bool
975 UnlockFile(UniqueHandle::pointer, std::uint64_t = 0,
976 std::uint64_t = std::uint64_t(-1)) ynothrow;
978
979
986 YF_API void
988 WaitUnique(UniqueHandle::pointer, unsigned long = INFINITE);
989
991 YF_API bool
992 TryWaitUnique(UniqueHandle::pointer, unsigned long = 0) ynothrow;
994
995
1001 class YF_API Mutex : private ystdex::noncopyable
1002 {
1003 public:
1004 using native_handle_type = UniqueHandle::pointer;
1005
1006 private:
1007 UniqueHandle h_mutex;
1008
1009 public:
1011 Mutex(const wchar_t*);
1012
1014 PDefH(void, lock, )
1015 ImplExpr(WaitUnique(native_handle()))
1016
1017 PDefH(bool, try_lock, ) ynothrow
1018 ImplRet(TryWaitUnique(native_handle()))
1019
1024 void
1025 unlock() ynothrowv;
1026
1028 PDefH(native_handle_type, native_handle, )
1029 ImplRet(h_mutex.get())
1030 };
1031
1032
1042 YF_API wstring
1043 FetchSystemPath(size_t = MAX_PATH);
1044
1049 YF_API wstring
1050 FetchWindowsPath(size_t = MAX_PATH);
1052
1053 } // inline namespace Windows;
1054
1055 } // namespace platform_ex;
1056
1057 #endif
1058
platform_ex::Windows::ReadOnly
Definition: MinGW32.h:449
ystdex::wrapped_enum_traits_t
_t< wrapped_enum_traits< _type >> wrapped_enum_traits_t
Definition: enum.hpp:54
platform_ex::Windows::DirectoryFindData::DirectoryFindData
DirectoryFindData(wstring_view sv)
构造：使用指定的目录路径。
Definition: MinGW32.h:698
platform_ex::Windows::SetFileTime
YF_API void SetFileTime(UniqueHandle::pointer,::FILETIME *={},::FILETIME *={},::FILETIME *={})
设置文件的创建、访问和/或修改时间。
platform_ex::Windows::WaitUnique
YF_API void WaitUnique(UniqueHandle::pointer, unsigned long=INFINITE)
以指定的时间间隔上限等待句柄指定的同步对象。
platform_ex::Windows::AccessRights::GenericRead
platform_ex::Windows::ValidFlags
Definition: MinGW32.h:501
platform_ex::Windows::OpenNoRecall
Definition: MinGW32.h:487
platform::containers::wstring
basic_string< wchar_t > wstring
Definition: Container.h:108
platform_ex::Windows::FileID
std::uint64_t FileID
文件标识。
Definition: MinGW32.h:825
platform_ex::Windows::POSIXSemantics
Definition: MinGW32.h:484
yconstfn
#define yconstfn
指定编译时常量函数。
Definition: ydef.h:680
platform_ex::Windows::ModuleProc
ystdex::remove_reference_t< decltype(*::GetProcAddress(::HMODULE(),{}))> ModuleProc
加载过程地址得到的过程类型。
Definition: MinGW32.h:222
platform_ex::Windows::AccessRights::All
platform_ex::Windows::QueryFileNodeID
YF_API pair< VolumeID, FileID > QueryFileNodeID(UniqueHandle::pointer)
查询文件标识。
DefBitmaskEnum
#define DefBitmaskEnum(_tEnum)
Definition: YBaseMacro.h:481
platform_ex::Windows::AccessRights::GenericExecute
platform_ex::Windows::ImplRet
yconstfnconst::WIN32_FIND_DATAA &d ynothrow ImplRet(IsDirectory(FileAttributes(d.dwFileAttributes))) inline PDefH(bool
判断 ::WIN32_FIND_DATAW 指定的节点是否为目录。
platform_ex::Windows::QueryFileSize
YF_API std::uint64_t QueryFileSize(UniqueHandle::pointer)
查询文件大小。
platform_ex::Windows::GlobalLocked::GlobalLocked
GlobalLocked(const _tPointer &p)
Definition: MinGW32.h:320
platform_ex::Windows::QueryFileTime
YF_API YB_NONNULL(1) std YF_API void QueryFileTime(UniqueHandle::pointer,::FILETIME *={},::FILETIME *={},::FILETIME *={})
查询文件的创建、访问和/或修改时间。
ystdex::to_string
std::string to_string(const std::thread::id &)
转换 thread::id 为字符串表示。
FileAttributesAndFlags
FileAttributesAndFlags
Definition: MinGW32.h:504
DefBoolNeg
#define DefBoolNeg(_spec,...)
定义表示显式转换 bool 操作符及其否定的 operator! 。
Definition: YBaseMacro.h:228
platform_ex::Windows::Present
Definition: MinGW32.h:500
ystdex::make_observer
observer_ptr< _type > make_observer(_type *p)
Definition: pointer.hpp:326
yalignof
#define yalignof(_type)
指定特定类型的对齐。
Definition: ydef.h:660
platform_ex::Windows::DirectoryFindData::Deleter
Definition: MinGW32.h:661
platform
默认平台命名空间。
Definition: Container.h:47
platform_ex::Windows::ContextTracking
Definition: MinGW32.h:495
platform::Deref
yconstfn auto Deref(_type &&p) -> decltype(*p)
断言并解引用非空指针。
Definition: Debug.h:451
platform_ex::Windows::FileAccessRights
YF_API FileAccessRights
Definition: MinGW32.h:593
platform_ex::Windows::TryWaitUnique
YF_API bool TryWaitUnique(UniqueHandle::pointer, unsigned long=0) ynothrow
platform_ex::Windows::AccessRights::Delete
platform_ex::Windows::GlobalDelete::pointer
::HGLOBAL pointer
Definition: MinGW32.h:298
platform_ex::Windows::FileShareMode
YF_API FileShareMode
Definition: MinGW32.h:594
platform_ex::Windows::SessionAware
Definition: MinGW32.h:485
ystdex::u16string_view
basic_string_view< char16_t > u16string_view
Definition: string_view.hpp:416
platform_ex::Windows::Device
Definition: MinGW32.h:454
ystdex::ends_with
bool ends_with(const _tRange1 &input, const _tRange2 &test, _fPred comp)
判断第一个参数指定的串是否以第二个参数结束。
Definition: string.hpp:417
platform_ex::Windows::AccessRights::StandardWrite
platform_ex::Windows::DirectoryFindData
文件系统目录查找状态。
Definition: MinGW32.h:657
ystdex::pun_ref::get
_type & get() const
Definition: type_pun.hpp:261
platform_ex::Windows::Encrypted
Definition: MinGW32.h:462
platform_ex::Windows::AccessRights::None
platform_ex::Windows::NoScrubData
Definition: MinGW32.h:467
FileAttributes
FileAttributes
文件共享模式。
Definition: MinGW32.h:447
platform::Descriptions::Emergent
Definition: YCommon.h:163
platform_ex::Windows::FirstPipeInstance
Definition: MinGW32.h:489
DefBitmaskOperations
#define DefBitmaskOperations(_tBitmask, _tInt)
Definition: YBaseMacro.h:468
platform_ex::Windows::attributes_and_flags
const wchar_t FileAccessRights FileShareMode FileAttributesAndFlags attributes_and_flags ynothrowv const wchar_t FileAccessRights CreationDisposition FileAttributesAndFlags attributes_and_flags
Definition: MinGW32.h:606
ystdex::cpp2014::cend
auto cend(const _tRange &c) -> decltype(std::end(c))
Definition: range.hpp:87
platform_ex::Windows::WriteThrough
Definition: MinGW32.h:477
platform_ex::Windows::GlobalLocked::p_locked
void * p_locked
Definition: MinGW32.h:310
platform::containers::string
basic_string< char > string
Definition: Container.h:101
platform_ex::Windows::LocalDelete::pointer
::HLOCAL pointer
Definition: MinGW32.h:342
platform_ex::Windows::EA
Definition: MinGW32.h:470
YCL_CallF_Win32
#define YCL_CallF_Win32(_fn,...)
Definition: MinGW32.h:190
platform_ex::Windows::AccessRights::WriteDAC
platform::KeyCodes::DS::L
Definition: Keys.h:227
platform_ex::Windows::ReparsePointData::target_buffer
ystdex::aligned_storage_t< MAXIMUM_REPARSE_DATA_BUFFER_SIZE, yalignof(void *)> target_buffer
Definition: MinGW32.h:770
platform_ex::Windows::proc
const char * proc
Definition: MinGW32.h:240
YB_PURE
#define YB_PURE
指示函数或函数模板实例为纯函数。
Definition: ydef.h:527
platform_ex::Windows::CategorizeNode
YF_API platform::NodeCategory CategorizeNode(FileAttributes, unsigned long=0) ynothrow
按 FileAttributes 和重解析标签归类节点类别。
platform_ex::Windows::System
Definition: MinGW32.h:451
SecurityQoS
SecurityQoS
Definition: MinGW32.h:492
platform_ex::Windows::AccessRights::WriteOwner
platform::Descriptions::RecordLevel
RecordLevel
记录等级。
Definition: YCommon.h:161
ystdex::cpp2014::aligned_storage_t
typename aligned_storage< _vLen, _vAlign >::type aligned_storage_t
Definition: type_traits.hpp:331
YB_ATTR_returns_nonnull
#define YB_ATTR_returns_nonnull
指示返回非空属性。
Definition: ydef.h:413
ystdex::wstring_view
basic_string_view< wchar_t > wstring_view
Definition: string_view.hpp:418
platform_ex::Windows::AccessRights
AccessRights
访问权限。
Definition: MinGW32.h:356
platform_ex::Windows::UnlockFile
bool UnlockFile(UniqueHandle::pointer, std::uint64_t=0, std::uint64_t=std::uint64_t(-1)) ynothrow
解锁文件。
YAssert
#define YAssert(_expr, _msg)
Definition: cassert.h:111
platform_ex::Windows::Mutex::h_mutex
UniqueHandle h_mutex
Definition: MinGW32.h:1007
platform_ex::Windows::Offline
Definition: MinGW32.h:460
platform_ex::Windows::AccessRights::StandardRead
platform_ex::Windows::path
const wchar_t * path
Definition: MinGW32.h:598
ynothrow
#define ynothrow
YSLib 无异常抛出保证：若支持 noexcept 关键字， 指定特定的 noexcept 异常规范。
Definition: ydef.h:766
platform_ex::Windows::SparseFile
Definition: MinGW32.h:457
platform_ex::Windows::AccessRights::Required
ystdex::cpp2014::cbegin
auto cbegin(const _tRange &c) -> decltype(std::begin(c))
Definition: range.hpp:79
ystdex
特性测试宏。
Definition: ydef.h:822
platform_ex::Windows::Overlapped
Definition: MinGW32.h:478
DefDeDtor
#define DefDeDtor(_t)
Definition: YBaseMacro.h:177
FileFlags
FileFlags
Definition: MinGW32.h:475
platform_ex::Windows::YB_NONNULL
YF_API YB_ATTR_returns_nonnull YB_NONNULL(2) ModuleProc *LoadProc( YB_NONNULL(2) _func &LoadProc(
从模块加载指定过程的指针。
Definition: MinGW32.h:232
platform_ex::Windows::AccessRights::GenericReadWrite
platform_ex::Windows::Invalid
Definition: MinGW32.h:471
platform_ex::Windows::Compressed
Definition: MinGW32.h:459
YF_API
#define YF_API
Definition: Platform.h:56
platform_ex::Windows::creation_disposition
const wchar_t FileAccessRights FileShareMode FileAttributesAndFlags attributes_and_flags ynothrowv const wchar_t FileAccessRights CreationDisposition creation_disposition
Definition: MinGW32.h:603
platform_ex::Windows::Identification
Definition: MinGW32.h:498
platform_ex::Windows::VolumeID
std::uint32_t VolumeID
卷序列号。
Definition: MinGW32.h:827
YModules.h
platform_ex::Windows::Virtual
Definition: MinGW32.h:465
platform_ex::Windows::Impersonation
Definition: MinGW32.h:499
ystdex::pun_ref< Data >
platform_ex::Windows::DeleteOnClose
Definition: MinGW32.h:482
platform_ex::Windows::AccessRights::Synchronize
platform_ex::Windows::IsDirectory
yconstfn IsDirectory
Definition: MinGW32.h:522
platform_ex::Windows::GlobalLocked
全局锁定存储。
Definition: MinGW32.h:306
ynothrowv
#define ynothrowv
YSLib 无异常抛出保证验证：有条件地使用无异常抛出规范。
Definition: ydef.h:786
platform_ex::Windows::NoBuffering
Definition: MinGW32.h:479
platform_ex::Windows::FetchWindowsPath
YF_API wstring FetchWindowsPath(size_t=MAX_PATH)
取系统目录路径。
platform_ex::Windows::AccessRights::GenericAll
platform_ex::Windows::QueryFileLinks
YF_API size_t QueryFileLinks(UniqueHandle::pointer)
查询文件链接数。
ystdex::cpp2014::remove_reference_t
typename remove_reference< _type >::type remove_reference_t
Definition: type_traits.hpp:299
std
Definition: memory.hpp:1183
platform_ex::Windows::TryLockFile
bool TryLockFile(UniqueHandle::pointer, std::uint64_t=0, std::uint64_t=std::uint64_t(-1), bool=true, bool=true) ynothrow
platform_ex::Windows::RandomAccess
Definition: MinGW32.h:480
DefGetter
#define DefGetter(_q, _t, _n,...)
Definition: YBaseMacro.h:241
platform_ex::Windows::ReparsePointData::pun
ystdex::pun_ref< Data > pun
Definition: MinGW32.h:777
platform_ex::Windows::NormalWithDirectory
Definition: MinGW32.h:506
platform_ex::Windows::NormalAll
Definition: MinGW32.h:507
DefCvt
#define DefCvt(_q, _t,...)
Definition: YBaseMacro.h:206
platform_ex::Windows::AccessRights::Execute
platform_ex::Windows::Mutex
互斥量：可用于进程间同步。
Definition: MinGW32.h:1001
platform::Descriptions::Err
Definition: YCommon.h:166
platform_ex::Windows::SequentialScan
Definition: MinGW32.h:481
DefDeCopyCtor
#define DefDeCopyCtor(_t)
Definition: YBaseMacro.h:162
platform_ex::Windows::MakeFile
MakeFile
Definition: MinGW32.h:598
ystdex::single_thread::try_lock
int try_lock(_tLock1 &&, _tLock2 &&, _tLocks &&...)
Definition: pseudo_mutex.h:983
platform_ex
平台扩展命名空间。
Definition: Android.h:45
platform_ex::Windows::CreationDisposition
YF_API CreationDisposition
Definition: MinGW32.h:595
YSLib::UI::name
yconstfn const string & name
Definition: Loader.h:130
platform_ex::Windows::shared_mode
const wchar_t FileAccessRights FileShareMode shared_mode
Definition: MinGW32.h:598
enum.hpp
枚举相关操作。
platform_ex::Windows::PDefH
PDefH(platform::NodeCategory, CategorizeNode, const ::WIN32_FIND_DATAA &d) ynothrow ImplRet(CategorizeNode(FileAttributes(d.dwFileAttributes)
按 ::WIN32_FIND_DATAA 归类节点类别。
platform_ex::Windows::ReparsePointData
重解析点数据。
Definition: MinGW32.h:767
platform_ex::Windows::FetchSystemPath
YF_API wstring FetchSystemPath(size_t=MAX_PATH)
取系统目录路径。
platform_ex::Windows::ErrorCode
unsigned long ErrorCode
Definition: MinGW32.h:57
platform_ex::Windows::LocalDelete
局部存储删除器。
Definition: MinGW32.h:340
platform_ex::Windows::TryCategorizeNodeDevice
yconstfnconst::WIN32_FIND_DATAA &d ynothrowconst::WIN32_FIND_DATAW &d ynothrow ImplRet(IsDirectory(FileAttributes(d.dwFileAttributes))) YF_API platform YF_API platform::NodeCategory TryCategorizeNodeDevice(UniqueHandle::pointer)
按打开的文件句柄归类节点从属的属性类别。
ystdex::single_thread::lock
void lock(_tLock1 &&, _tLock2 &&, _tLocks &&...)
Definition: pseudo_mutex.h:990
platform_ex::Windows::desired_access
const wchar_t FileAccessRights desired_access
Definition: MinGW32.h:598
platform_ex::Windows::GlobalLocked::GetPtr
observer_ptr< _type > GetPtr() const ynothrow
Definition: MinGW32.h:328
platform_ex::Windows::Archive
Definition: MinGW32.h:453
platform_ex::Windows::IntegrityStream
Definition: MinGW32.h:464
platform_ex::Windows::Hidden
Definition: MinGW32.h:450
platform_ex::Windows::EffectiveOnly
Definition: MinGW32.h:497
platform_ex::Windows::Anonymous
Definition: MinGW32.h:494
CHRLib::d
_tDst * d
Definition: CharacterProcessing.h:139
platform_ex::Windows::DirectoryFindData::DirectoryFindData
DirectoryFindData(u16string_view sv)
Definition: MinGW32.h:702
platform_ex::Windows::Temporary
Definition: MinGW32.h:456
platform_ex::Windows::BackupSemantics
Definition: MinGW32.h:483
platform_ex::Windows::ConvertTime
YF_API std::chrono::nanoseconds ConvertTime(const ::FILETIME &)
转换文件时间为以 POSIX 历元起始度量的时间间隔。
platform_ex::Windows::AccessRights::ReadControl
platform_ex::Windows::AccessRights::MaximumAllowed
platform_ex::Windows::Delegation
Definition: MinGW32.h:496
platform_ex::Windows::NotContentIndexed
Definition: MinGW32.h:461
platform_ex::Windows::AccessRights::AccessSystemACL
platform_ex::Windows::ReparsePoint
Definition: MinGW32.h:458
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:99
platform_ex::Windows::ConvertToErrno
YF_API YB_STATELESS int ConvertToErrno(ErrorCode) ynothrow
转换 Win32 错误为 errno 。
platform_ex::Windows::OpenReparsePoint
Definition: MinGW32.h:486
platform_ex::Windows::AccessRights::GenericWrite
platform_ex::Windows::LockFile
void LockFile(UniqueHandle::pointer, std::uint64_t=0, std::uint64_t=std::uint64_t(-1), bool=true, bool={})
锁定文件。
platform_ex::Windows::FetchModuleFileName
YF_API wstring FetchModuleFileName(::HMODULE={}, YSLib::RecordLevel=YSLib::Err)
取模块映像路径。
ystdex::string_view
basic_string_view< char > string_view
Definition: string_view.hpp:415
platform_ex::Windows::Normal
Definition: MinGW32.h:455
platform_ex::Windows::Mutex::native_handle_type
UniqueHandle::pointer native_handle_type
Definition: MinGW32.h:1004
CHRLib::p
const auto p(d)
platform_ex::Windows::Directory
Definition: MinGW32.h:452
YB_STATELESS
#define YB_STATELESS
指示函数或函数模板实例为无状态函数。
Definition: ydef.h:548
ystdex::details::get
get())
Definition: cast.hpp:102