diff options
author | Yuqian Yang <crupest@crupest.life> | 2025-09-04 22:51:27 +0800 |
---|---|---|
committer | Yuqian Yang <crupest@crupest.life> | 2025-09-04 22:51:27 +0800 |
commit | fdddc7f4a8884a8481dc71c0f34b8775659ba236 (patch) | |
tree | 7b43bc30a7666f4dc2a87e7999a9f26d911dbe66 /include/cru | |
parent | 2ac35f7b67eac709cdae7981880f7d117f9a9d75 (diff) | |
download | cru-fdddc7f4a8884a8481dc71c0f34b8775659ba236.tar.gz cru-fdddc7f4a8884a8481dc71c0f34b8775659ba236.tar.bz2 cru-fdddc7f4a8884a8481dc71c0f34b8775659ba236.zip |
UnixFileDescriptor Read and ErrnoException std::string.
Diffstat (limited to 'include/cru')
-rw-r--r-- | include/cru/base/Exception.h | 17 | ||||
-rw-r--r-- | include/cru/base/platform/unix/UnixFile.h | 2 |
2 files changed, 12 insertions, 7 deletions
diff --git a/include/cru/base/Exception.h b/include/cru/base/Exception.h index d102c263..a898043a 100644 --- a/include/cru/base/Exception.h +++ b/include/cru/base/Exception.h @@ -3,6 +3,7 @@ #include <exception> #include <optional> +#include <string_view> namespace cru { #ifdef _MSC_VER @@ -53,16 +54,18 @@ class CRU_BASE_API TextEncodeException : public Exception { class ErrnoException : public Exception { public: + ErrnoException(); + explicit ErrnoException(int error_code); /** * @brief will retrieve errno automatically. */ - explicit ErrnoException(String message = {}); - ErrnoException(String message, int errno_code); - - CRU_DELETE_COPY(ErrnoException) - CRU_DELETE_MOVE(ErrnoException) - - ~ErrnoException() override = default; + explicit ErrnoException(std::string_view message); + ErrnoException(std::string_view message, int errno_code); + /** + * @brief will retrieve errno automatically. + */ + explicit ErrnoException(StringView message); + ErrnoException(StringView message, int errno_code); int GetErrnoCode() const { return errno_code_; } diff --git a/include/cru/base/platform/unix/UnixFile.h b/include/cru/base/platform/unix/UnixFile.h index dfbdfffb..8ce3249d 100644 --- a/include/cru/base/platform/unix/UnixFile.h +++ b/include/cru/base/platform/unix/UnixFile.h @@ -6,6 +6,7 @@ #include "../../Bitmask.h" +#include <sys/types.h> #include <functional> namespace cru::platform::unix { @@ -36,6 +37,7 @@ class UnixFileDescriptor { explicit operator bool() const { return this->IsValid(); } operator int() const { return this->GetValue(); } + ssize_t Read(void* buffer, size_t size); void SetFileDescriptorFlags(int flags); private: |