diff options
| author | crupest <crupest@outlook.com> | 2022-01-25 00:09:19 +0800 | 
|---|---|---|
| committer | crupest <crupest@outlook.com> | 2022-01-25 00:09:19 +0800 | 
| commit | 6b34acefdbf82e3bcc5d3a103ecb2118ae05b81e (patch) | |
| tree | 06e56cc868dcbdd5062a15e87dc7baec320c8b4b /include/cru/common/io/Win32FileStream.hpp | |
| parent | 24e1dc8723aea1e46a3aa15794747f3fa52f8eca (diff) | |
| download | cru-6b34acefdbf82e3bcc5d3a103ecb2118ae05b81e.tar.gz cru-6b34acefdbf82e3bcc5d3a103ecb2118ae05b81e.tar.bz2 cru-6b34acefdbf82e3bcc5d3a103ecb2118ae05b81e.zip  | |
...
Diffstat (limited to 'include/cru/common/io/Win32FileStream.hpp')
| -rw-r--r-- | include/cru/common/io/Win32FileStream.hpp | 53 | 
1 files changed, 53 insertions, 0 deletions
diff --git a/include/cru/common/io/Win32FileStream.hpp b/include/cru/common/io/Win32FileStream.hpp new file mode 100644 index 00000000..08600a8e --- /dev/null +++ b/include/cru/common/io/Win32FileStream.hpp @@ -0,0 +1,53 @@ +#pragma once + +#include "../PreConfig.hpp" + +#ifdef CRU_PLATFORM_WINDOWS + +#include "../String.hpp" +#include "OpenFileFlag.hpp" +#include "Stream.hpp" +#include "cru/common/Base.hpp" + +namespace cru::io { +namespace details { +class Win32FileStreamPrivate; +} + +class CRU_BASE_API Win32FileStream : public Stream { + public: +  Win32FileStream(String path, OpenFileFlag flags); + +  CRU_DELETE_COPY(Win32FileStream) +  CRU_DELETE_MOVE(Win32FileStream) + +  ~Win32FileStream() override; + + public: +  bool CanSeek() override; +  Index Tell() override; +  void Seek(Index offset, SeekOrigin origin = SeekOrigin::Current) override; + +  bool CanRead() override; +  Index Read(std::byte* buffer, Index offset, Index size) override; +  using Stream::Read; + +  bool CanWrite() override; +  Index Write(const std::byte* buffer, Index offset, Index size) override; +  using Stream::Write; + +  void Close() override; + + private: +  void CheckClosed(); + + private: +  String path_; +  OpenFileFlag flags_; +  bool closed_ = false; + +  details::Win32FileStreamPrivate* p_; +}; +}  // namespace cru::io + +#endif  | 
