diff options
| author | Dan Engelbrecht <[email protected]> | 2022-11-17 13:13:46 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2022-11-17 04:13:46 -0800 |
| commit | 4c95b15f90bf99104c8b528ef0ac2da05c86c612 (patch) | |
| tree | 1f46ad87e58fb4f7a5cb44df59f6ecbec41835e6 /zenstore/include | |
| parent | actions/[email protected] -> actions/checkout@v3 (diff) | |
| download | zen-4c95b15f90bf99104c8b528ef0ac2da05c86c612.tar.xz zen-4c95b15f90bf99104c8b528ef0ac2da05c86c612.zip | |
move BasicFile to zenutil to remove zenstore dependency from zen command (#190)
Diffstat (limited to 'zenstore/include')
| -rw-r--r-- | zenstore/include/zenstore/basicfile.h | 115 | ||||
| -rw-r--r-- | zenstore/include/zenstore/blockstore.h | 2 | ||||
| -rw-r--r-- | zenstore/include/zenstore/caslog.h | 2 |
3 files changed, 2 insertions, 117 deletions
diff --git a/zenstore/include/zenstore/basicfile.h b/zenstore/include/zenstore/basicfile.h deleted file mode 100644 index ce9988776..000000000 --- a/zenstore/include/zenstore/basicfile.h +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright Epic Games, Inc. All Rights Reserved. - -#pragma once - -#include "zenstore.h" - -#include <zencore/iobuffer.h> - -#include <filesystem> -#include <functional> - -namespace zen { - -class CbObject; - -/** - * Probably the most basic file abstraction in the universe - * - * One thing of note is that there is no notion of a "current file position" - * in this API -- all reads and writes are done from explicit offsets in - * the file. This avoids concurrency issues which can occur otherwise. - * - */ - -class BasicFile -{ -public: - BasicFile() = default; - ~BasicFile(); - - BasicFile(const BasicFile&) = delete; - BasicFile& operator=(const BasicFile&) = delete; - - enum class Mode : uint32_t - { - kRead = 0, // Opens a existing file for read only - kWrite = 1, // Opens (or creates) a file for read and write - kTruncate = 2, // Opens (or creates) a file for read and write and sets the size to zero - kDelete = 3, // Opens (or creates) a file for read and write allowing .DeleteFile file disposition to be set - kTruncateDelete = - 4 // Opens (or creates) a file for read and write and sets the size to zero allowing .DeleteFile file disposition to be set - }; - - void Open(const std::filesystem::path& FileName, Mode Mode); - void Open(const std::filesystem::path& FileName, Mode Mode, std::error_code& Ec); - void Close(); - void Read(void* Data, uint64_t Size, uint64_t FileOffset); - void StreamFile(std::function<void(const void* Data, uint64_t Size)>&& ChunkFun); - void StreamByteRange(uint64_t FileOffset, uint64_t Size, std::function<void(const void* Data, uint64_t Size)>&& ChunkFun); - void Write(MemoryView Data, uint64_t FileOffset); - void Write(MemoryView Data, uint64_t FileOffset, std::error_code& Ec); - void Write(const void* Data, uint64_t Size, uint64_t FileOffset); - void Write(const void* Data, uint64_t Size, uint64_t FileOffset, std::error_code& Ec); - void Flush(); - uint64_t FileSize(); - void SetFileSize(uint64_t FileSize); - IoBuffer ReadAll(); - void WriteAll(IoBuffer Data, std::error_code& Ec); - void* Detach(); - - inline void* Handle() { return m_FileHandle; } - -protected: - void* m_FileHandle = nullptr; // This is either null or valid -private: -}; - -/** - * Simple abstraction for a temporary file - * - * Works like a regular BasicFile but implements a simple mechanism to allow creating - * a temporary file for writing in a directory which may later be moved atomically - * into the intended location after it has been fully written to. - * - */ - -class TemporaryFile : public BasicFile -{ -public: - TemporaryFile() = default; - ~TemporaryFile(); - - TemporaryFile(const TemporaryFile&) = delete; - TemporaryFile& operator=(const TemporaryFile&) = delete; - - void Close(); - void CreateTemporary(std::filesystem::path TempDirName, std::error_code& Ec); - void MoveTemporaryIntoPlace(std::filesystem::path FinalFileName, std::error_code& Ec); - const std::filesystem::path& GetPath() const { return m_TempPath; } - -private: - std::filesystem::path m_TempPath; - - using BasicFile::Open; -}; - -/** Lock file abstraction - - */ - -class LockFile : protected BasicFile -{ -public: - LockFile(); - ~LockFile(); - - void Create(std::filesystem::path FileName, CbObject Payload, std::error_code& Ec); - void Update(CbObject Payload, std::error_code& Ec); - -private: -}; - -ZENCORE_API void basicfile_forcelink(); - -} // namespace zen diff --git a/zenstore/include/zenstore/blockstore.h b/zenstore/include/zenstore/blockstore.h index db32efb9f..9f16063a0 100644 --- a/zenstore/include/zenstore/blockstore.h +++ b/zenstore/include/zenstore/blockstore.h @@ -4,7 +4,7 @@ #include <zencore/filesystem.h> #include <zencore/zencore.h> -#include <zenstore/basicfile.h> +#include <zenutil/basicfile.h> #include <unordered_map> #include <unordered_set> diff --git a/zenstore/include/zenstore/caslog.h b/zenstore/include/zenstore/caslog.h index c56b653fc..1aeb50d05 100644 --- a/zenstore/include/zenstore/caslog.h +++ b/zenstore/include/zenstore/caslog.h @@ -3,7 +3,7 @@ #pragma once #include <zencore/uid.h> -#include <zenstore/basicfile.h> +#include <zenutil/basicfile.h> namespace zen { |