From 1550828518ff4719db88f35e088207816866a073 Mon Sep 17 00:00:00 2001 From: crupest Date: Thu, 5 Oct 2023 22:02:25 +0800 Subject: ... --- src/common/io/CFileStream.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/common/io/CFileStream.cpp') diff --git a/src/common/io/CFileStream.cpp b/src/common/io/CFileStream.cpp index de195538..29d4819f 100644 --- a/src/common/io/CFileStream.cpp +++ b/src/common/io/CFileStream.cpp @@ -97,6 +97,7 @@ bool CFileStream::CanRead() { Index CFileStream::Read(std::byte* buffer, Index offset, Index size) { CheckClosed(); + StreamOperationNotSupportedException::CheckRead(readable_); auto count = std::fread(buffer + offset, 1, size, file_); return count; } @@ -108,6 +109,7 @@ bool CFileStream::CanWrite() { Index CFileStream::Write(const std::byte* buffer, Index offset, Index size) { CheckClosed(); + StreamOperationNotSupportedException::CheckWrite(writable_); auto count = std::fwrite(buffer + offset, 1, size, file_); return count; } @@ -125,8 +127,6 @@ void CFileStream::Close() { } void CFileStream::CheckClosed() { - if (file_ == nullptr) { - throw StreamAlreadyClosedException(u"File is closed."); - } + StreamAlreadyClosedException::Check(file_ == nullptr); } } // namespace cru::io -- cgit v1.2.3