aboutsummaryrefslogtreecommitdiff
path: root/include/cru/common/io
diff options
context:
space:
mode:
Diffstat (limited to 'include/cru/common/io')
-rw-r--r--include/cru/common/io/CFileStream.h2
-rw-r--r--include/cru/common/io/FileNotExistException.h19
-rw-r--r--include/cru/common/io/FileStream.h46
-rw-r--r--include/cru/common/io/Stream.h2
4 files changed, 3 insertions, 66 deletions
diff --git a/include/cru/common/io/CFileStream.h b/include/cru/common/io/CFileStream.h
index 65de2ac7..be23ac4a 100644
--- a/include/cru/common/io/CFileStream.h
+++ b/include/cru/common/io/CFileStream.h
@@ -24,9 +24,11 @@ class CRU_BASE_API CFileStream : public Stream {
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;
diff --git a/include/cru/common/io/FileNotExistException.h b/include/cru/common/io/FileNotExistException.h
deleted file mode 100644
index f49271b1..00000000
--- a/include/cru/common/io/FileNotExistException.h
+++ /dev/null
@@ -1,19 +0,0 @@
-#pragma once
-
-#include "../Base.h"
-#include "../Exception.h"
-
-namespace cru::io {
- class CRU_BASE_API FileNotExistException : public Exception {
- public:
- FileNotExistException(String path);
-
- CRU_DEFAULT_COPY(FileNotExistException)
- CRU_DEFAULT_MOVE(FileNotExistException)
-
- ~FileNotExistException() override = default;
-
- private:
- String path_;
- };
-}
diff --git a/include/cru/common/io/FileStream.h b/include/cru/common/io/FileStream.h
deleted file mode 100644
index 4eab612f..00000000
--- a/include/cru/common/io/FileStream.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/**
- * Here are some notes about FileStream:
- *
- * 1. FileStream is currently implemented as a typedef of the corresponding
- * specific XxxFileStream class implemented on each platform and controlled with
- * preprocessor commands. There might be some other ways like proxy pattern but
- * I do this way for simplicity. So your duty to implement a new platform is to
- * define a new class and ensure it implements all the required interface. And
- * in this way you are free to expose any other additional interface like for
- * specific platform.
- *
- * 2. Since each platform defines their own way to open a file, especially the
- * flags to open a file, we have to define a common interface. I decide to
- * mimic Linux flags so on platforms where there is no direct support on certain
- * flags we try our best to simulate it and make a note for users.
- *
- * (TODO: Currently the problem is that when I implemented for Windows and UNIX
- * I didn't take this into consideration so I have to fix this inconsistency
- * later.)
- *
- * The requirement of FileStream:
- * 1. It must be derived from Stream, of course.
- * 2. It must have a constructor FileStream(String path, io::OpenFlag flags), so
- * user can construct one with the same interface.
- */
-
-#pragma once
-
-#include "../PreConfig.h"
-
-#ifdef CRU_PLATFORM_UNIX
-#include "../platform/unix/UnixFileStream.h"
-namespace cru::io {
-using FileStream = platform::unix::UnixFileStream;
-}
-#elif CRU_PLATFORM_WINDOWS
-#include "../platform/win/Win32FileStream.h"
-namespace cru::io {
-using FileStream = platform::win::Win32FileStream;
-}
-#elif CRU_PLATFORM_EMSCRIPTEN
-#include "../platform/web/WebFileStream.h"
-namespace cru::io {
-using FileStream = platform::web::WebFileStream;
-}
-#endif
diff --git a/include/cru/common/io/Stream.h b/include/cru/common/io/Stream.h
index 2388874e..d24931da 100644
--- a/include/cru/common/io/Stream.h
+++ b/include/cru/common/io/Stream.h
@@ -32,7 +32,7 @@ class CRU_BASE_API StreamOperationNotSupportedException : public Exception {
class CRU_BASE_API StreamAlreadyClosedException : public Exception {
public:
- using Exception::Exception;
+ StreamAlreadyClosedException();
CRU_DEFAULT_COPY(StreamAlreadyClosedException)
CRU_DEFAULT_MOVE(StreamAlreadyClosedException)