aboutsummaryrefslogtreecommitdiff
path: root/include/cru/common/io/CFileStream.h
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2024-06-24 00:06:25 +0800
committercrupest <crupest@outlook.com>2024-10-04 19:55:33 +0800
commitf51eb955e188858272230a990565931e7403f23b (patch)
tree04de484bfcd056b6eea56c13c42cce83315c448f /include/cru/common/io/CFileStream.h
parent1b30150ab79ff1338f209a8ddb54b3dc60cfb599 (diff)
downloadcru-f51eb955e188858272230a990565931e7403f23b.tar.gz
cru-f51eb955e188858272230a990565931e7403f23b.tar.bz2
cru-f51eb955e188858272230a990565931e7403f23b.zip
HALF WORK: Stream refactor.
TODO: Complete refactor of BufferStream and AutoReadStream. NEED TEST: BufferStream, AutoReadStream, SubProcess.
Diffstat (limited to 'include/cru/common/io/CFileStream.h')
-rw-r--r--include/cru/common/io/CFileStream.h29
1 files changed, 10 insertions, 19 deletions
diff --git a/include/cru/common/io/CFileStream.h b/include/cru/common/io/CFileStream.h
index be23ac4a..0b58bdc9 100644
--- a/include/cru/common/io/CFileStream.h
+++ b/include/cru/common/io/CFileStream.h
@@ -17,32 +17,23 @@ class CRU_BASE_API CFileStream : public Stream {
~CFileStream() override;
public:
- bool CanSeek() override;
- Index Seek(Index offset, SeekOrigin origin = SeekOrigin::Current) override;
- Index Tell() override;
- void Rewind() 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 Flush() override;
-
- void Close() override;
+ CRU_STREAM_IMPLEMENT_CLOSE_BY_DO_CLOSE
std::FILE* GetHandle() const;
+ protected:
+ Index DoSeek(Index offset, SeekOrigin origin) override;
+ Index DoTell() override;
+ void DoRewind() override;
+ Index DoRead(std::byte* buffer, Index offset, Index size) override;
+ Index DoWrite(const std::byte* buffer, Index offset, Index size) override;
+ void DoFlush() override;
+
private:
- void CheckClosed();
+ void DoClose();
private:
std::FILE* file_;
- bool readable_;
- bool writable_;
bool auto_close_;
};
} // namespace cru::io