aboutsummaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/common')
-rw-r--r--src/common/CMakeLists.txt1
-rw-r--r--src/common/io/ProxyStream.cpp18
2 files changed, 19 insertions, 0 deletions
diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt
index 714a4636..45688deb 100644
--- a/src/common/CMakeLists.txt
+++ b/src/common/CMakeLists.txt
@@ -9,6 +9,7 @@ add_library(CruBase
SubProcess.cpp
io/CFileStream.cpp
io/Stream.cpp
+ io/ProxyStream.cpp
io/Resource.cpp
io/MemoryStream.cpp
log/Logger.cpp
diff --git a/src/common/io/ProxyStream.cpp b/src/common/io/ProxyStream.cpp
new file mode 100644
index 00000000..9fd6be76
--- /dev/null
+++ b/src/common/io/ProxyStream.cpp
@@ -0,0 +1,18 @@
+#include "cru/common/io/ProxyStream.h"
+#include "cru/common/io/Stream.h"
+
+namespace cru::io {
+ProxyStream::ProxyStream(ProxyStreamHandlers handlers)
+ : closed_(false), handlers_(std::move(handlers)) {}
+
+ProxyStream::~ProxyStream() { DoClose(); }
+
+void ProxyStream::DoClose() {
+ if (!closed_) {
+ if (handlers_.close) {
+ handlers_.close();
+ }
+ closed_ = true;
+ }
+}
+} // namespace cru::io