aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2021-10-01 18:50:32 +0200
committerStefan Boberg <[email protected]>2021-10-01 18:50:32 +0200
commit4e5fe27def24e21d7e105f59ab98e0c4c80c87dc (patch)
treeba476a3955550ea0362e5fdff2ebeb8f06a07a38
parentstructured cache: Fixed package payload endpoint handling of HEAD (diff)
downloadzen-4e5fe27def24e21d7e105f59ab98e0c4c80c87dc.tar.xz
zen-4e5fe27def24e21d7e105f59ab98e0c4c80c87dc.zip
filesystem: Added FileContents::Flatten() and ensured it's possible to #include filesystem.h standalone
-rw-r--r--zen/cmds/run.cpp1
-rw-r--r--zencore/filesystem.cpp17
-rw-r--r--zencore/include/zencore/filesystem.h5
3 files changed, 22 insertions, 1 deletions
diff --git a/zen/cmds/run.cpp b/zen/cmds/run.cpp
index 94eb7ef6d..19b5c8980 100644
--- a/zen/cmds/run.cpp
+++ b/zen/cmds/run.cpp
@@ -10,6 +10,7 @@
#include <zencore/fmtutils.h>
#include <zencore/iohash.h>
#include <zencore/logging.h>
+#include <zencore/stream.h>
#include <zencore/string.h>
#include <zencore/timer.h>
#include <zenutil/zenserverprocess.h>
diff --git a/zencore/filesystem.cpp b/zencore/filesystem.cpp
index 1d6b2f61c..f6ba92f98 100644
--- a/zencore/filesystem.cpp
+++ b/zencore/filesystem.cpp
@@ -522,6 +522,23 @@ WriteFile(std::filesystem::path Path, IoBuffer Data)
WriteFile(Path, &DataPtr, 1);
}
+IoBuffer
+FileContents::Flatten()
+{
+ if (Data.size() == 1)
+ {
+ return Data[0];
+ }
+ else if (Data.empty())
+ {
+ return {};
+ }
+ else
+ {
+ ZEN_NOT_IMPLEMENTED();
+ }
+}
+
FileContents
ReadFile(std::filesystem::path Path)
{
diff --git a/zencore/include/zencore/filesystem.h b/zencore/include/zencore/filesystem.h
index 6678528f6..c7ac7140d 100644
--- a/zencore/include/zencore/filesystem.h
+++ b/zencore/include/zencore/filesystem.h
@@ -2,9 +2,10 @@
#pragma once
-#include "stream.h"
#include "zencore.h"
+#include <zencore/iobuffer.h>
+
#include <filesystem>
#include <functional>
@@ -36,6 +37,8 @@ struct FileContents
{
std::vector<IoBuffer> Data;
std::error_code ErrorCode;
+
+ IoBuffer Flatten();
};
ZENCORE_API FileContents ReadFile(std::filesystem::path Path);