diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/cru/common/io/Stream.h | 23 | ||||
-rw-r--r-- | include/cru/common/platform/unix/UnixFileStream.h | 15 |
2 files changed, 31 insertions, 7 deletions
diff --git a/include/cru/common/io/Stream.h b/include/cru/common/io/Stream.h index f833b0b9..2388874e 100644 --- a/include/cru/common/io/Stream.h +++ b/include/cru/common/io/Stream.h @@ -9,6 +9,27 @@ #include <vector> namespace cru::io { +class CRU_BASE_API StreamOperationNotSupportedException : public Exception { + public: + explicit StreamOperationNotSupportedException(String operation); + + CRU_DEFAULT_COPY(StreamOperationNotSupportedException) + CRU_DEFAULT_MOVE(StreamOperationNotSupportedException) + + CRU_DEFAULT_DESTRUCTOR(StreamOperationNotSupportedException) + + public: + String GetOperation() const { return operation_; } + + public: + static void CheckSeek(bool seekable); + static void CheckRead(bool readable); + static void CheckWrite(bool writable); + + private: + String operation_; +}; + class CRU_BASE_API StreamAlreadyClosedException : public Exception { public: using Exception::Exception; @@ -17,6 +38,8 @@ class CRU_BASE_API StreamAlreadyClosedException : public Exception { CRU_DEFAULT_MOVE(StreamAlreadyClosedException) CRU_DEFAULT_DESTRUCTOR(StreamAlreadyClosedException) + + static void Check(bool closed); }; class CRU_BASE_API Stream : public Object { diff --git a/include/cru/common/platform/unix/UnixFileStream.h b/include/cru/common/platform/unix/UnixFileStream.h index 0c8ef340..bf13358b 100644 --- a/include/cru/common/platform/unix/UnixFileStream.h +++ b/include/cru/common/platform/unix/UnixFileStream.h @@ -4,14 +4,14 @@ #ifdef CRU_PLATFORM_UNIX -#include "../../String.h" -#include "../../io/OpenFileFlag.h" #include "../../io/Stream.h" namespace cru::platform::unix { class UnixFileStream : public io::Stream { public: - UnixFileStream(String path, io::OpenFileFlag flags); + UnixFileStream(const char* path, int oflag); + UnixFileStream(int fd, bool can_seek, bool can_read, bool can_write, + bool auto_close); CRU_DELETE_COPY(UnixFileStream) CRU_DELETE_MOVE(UnixFileStream) @@ -36,10 +36,11 @@ class UnixFileStream : public io::Stream { void CheckClosed(); private: - String path_; - io::OpenFileFlag flags_; - int file_descriptor_; - bool closed_ = false; + int file_descriptor_; // -1 for no file descriptor + bool can_seek_; + bool can_read_; + bool can_write_; + bool auto_close_; }; } // namespace cru::platform::unix |