From 246eb9266b9349b44cbe96f3f839124ab30cbb89 Mon Sep 17 00:00:00 2001 From: Yuqian Yang Date: Sat, 15 Nov 2025 16:43:25 +0800 Subject: Impl win subprocess. --- include/cru/base/io/Base.h | 62 ++++++++++++++++++++++++++++++++++++++ include/cru/base/io/OpenFileFlag.h | 56 ---------------------------------- include/cru/base/io/Stream.h | 2 +- 3 files changed, 63 insertions(+), 57 deletions(-) create mode 100644 include/cru/base/io/Base.h delete mode 100644 include/cru/base/io/OpenFileFlag.h (limited to 'include/cru/base/io') diff --git a/include/cru/base/io/Base.h b/include/cru/base/io/Base.h new file mode 100644 index 00000000..d5e2abff --- /dev/null +++ b/include/cru/base/io/Base.h @@ -0,0 +1,62 @@ +#pragma once + +#include "../Base.h" +#include "../Bitmask.h" + +namespace cru::io { +class CRU_BASE_API FileNotExistException : public Exception { + public: + using Exception::Exception; +}; + +namespace details { +struct OpenFileFlagTag {}; +} // namespace details +using OpenFileFlag = Bitmask; + +struct OpenFileFlags { + /** + * \brief for reading + * If the file does not exist, FileNotExistException should be thrown. + */ + static constexpr OpenFileFlag Read{0x1}; + + /** + * \brief for writing + * If the file does not exist and Create is not specified, + * FileNotExistException should be thrown. + */ + static constexpr OpenFileFlag Write{0x2}; + + /** + * \brief when writing, seek to end first + * Only effective for writing. + */ + static constexpr OpenFileFlag Append{0x4}; + + /** + * \brief when writing, truncate the file to empty + * Only effective for writing. + * So the content is erased! Be careful! + */ + static constexpr OpenFileFlag Truncate{0x8}; + + /** + * \brief when writing, if the file does not exist, create one + * Only effective for writing. When file does not exist, FileNotExistException + * will NOT be thrown and a new file will be created. + */ + static constexpr OpenFileFlag Create{0x10}; + + /** + * TODO: ??? + */ + static constexpr OpenFileFlag Exclusive{0x20}; +}; + +/** + * Append, Truncate, Create must be used with Write. + * Append and Truncate must not be used together. + */ +bool CheckOpenFileFlag(OpenFileFlag flags); +} // namespace cru::io diff --git a/include/cru/base/io/OpenFileFlag.h b/include/cru/base/io/OpenFileFlag.h deleted file mode 100644 index 4a5789fb..00000000 --- a/include/cru/base/io/OpenFileFlag.h +++ /dev/null @@ -1,56 +0,0 @@ -#pragma once - -#include "../Bitmask.h" - -namespace cru::io { -namespace details { -struct OpenFileFlagTag {}; -} // namespace details -using OpenFileFlag = Bitmask; - -struct OpenFileFlags { - /** - * \brief for reading - * If the file does not exist, FileNotExistException should be thrown. - */ - static constexpr OpenFileFlag Read{0x1}; - - /** - * \brief for writing - * If the file does not exist and Create is not specified, - * FileNotExistException should be thrown. - */ - static constexpr OpenFileFlag Write{0x2}; - - /** - * \brief when writing, seek to end first - * Only effective for writing. - */ - static constexpr OpenFileFlag Append{0x4}; - - /** - * \brief when writing, truncate the file to empty - * Only effective for writing. - * So the content is erased! Be careful! - */ - static constexpr OpenFileFlag Truncate{0x8}; - - /** - * \brief when writing, if the file does not exist, create one - * Only effective for writing. When file does not exist, FileNotExistException - * will NOT be thrown and a new file will be created. - */ - static constexpr OpenFileFlag Create{0x10}; - - /** - * TODO: ??? - */ - static constexpr OpenFileFlag Exclusive{0x20}; -}; - -/** - * Append, Truncate, Create must be used with Write. - * Append and Truncate must not be used together. - */ -bool CheckOpenFileFlag(OpenFileFlag flags); -} // namespace cru::io diff --git a/include/cru/base/io/Stream.h b/include/cru/base/io/Stream.h index 503ccd27..cbcb3ced 100644 --- a/include/cru/base/io/Stream.h +++ b/include/cru/base/io/Stream.h @@ -113,7 +113,7 @@ class CRU_BASE_API Stream : public Object { void CheckClosed() { StreamClosedException::Check(closed_); } private: - std::optional supported_operations_; + SupportedOperations supported_operations_; bool closed_; }; } // namespace cru::io -- cgit v1.2.3