diff options
| author | Stefan Boberg <[email protected]> | 2023-05-02 10:01:47 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-05-02 10:01:47 +0200 |
| commit | 075d17f8ada47e990fe94606c3d21df409223465 (patch) | |
| tree | e50549b766a2f3c354798a54ff73404217b4c9af /zencore/iohash.cpp | |
| parent | fix: bundle shouldn't append content zip to zen (diff) | |
| download | zen-075d17f8ada47e990fe94606c3d21df409223465.tar.xz zen-075d17f8ada47e990fe94606c3d21df409223465.zip | |
moved source directories into `/src` (#264)
* moved source directories into `/src`
* updated bundle.lua for new `src` path
* moved some docs, icon
* removed old test trees
Diffstat (limited to 'zencore/iohash.cpp')
| -rw-r--r-- | zencore/iohash.cpp | 87 |
1 files changed, 0 insertions, 87 deletions
diff --git a/zencore/iohash.cpp b/zencore/iohash.cpp deleted file mode 100644 index 77076c133..000000000 --- a/zencore/iohash.cpp +++ /dev/null @@ -1,87 +0,0 @@ -// Copyright Epic Games, Inc. All Rights Reserved. - -#include <zencore/iohash.h> - -#include <zencore/blake3.h> -#include <zencore/compositebuffer.h> -#include <zencore/string.h> -#include <zencore/testing.h> - -#include <gsl/gsl-lite.hpp> - -namespace zen { - -const IoHash IoHash::Zero{}; // Initialized to all zeros - -IoHash -IoHash::HashBuffer(const void* data, size_t byteCount) -{ - BLAKE3 b3 = BLAKE3::HashMemory(data, byteCount); - - IoHash io; - memcpy(io.Hash, b3.Hash, sizeof io.Hash); - - return io; -} - -IoHash -IoHash::HashBuffer(const CompositeBuffer& Buffer) -{ - IoHashStream Hasher; - - for (const SharedBuffer& Segment : Buffer.GetSegments()) - { - Hasher.Append(Segment.GetData(), Segment.GetSize()); - } - - return Hasher.GetHash(); -} - -IoHash -IoHash::FromHexString(const char* string) -{ - return FromHexString({string, sizeof(IoHash::Hash) * 2}); -} - -IoHash -IoHash::FromHexString(std::string_view string) -{ - ZEN_ASSERT(string.size() == 2 * sizeof(IoHash::Hash)); - - IoHash io; - - ParseHexBytes(string.data(), string.size(), io.Hash); - - return io; -} - -const char* -IoHash::ToHexString(char* outString /* 40 characters + NUL terminator */) const -{ - ToHexBytes(Hash, sizeof(IoHash), outString); - outString[2 * sizeof(IoHash)] = '\0'; - - return outString; -} - -StringBuilderBase& -IoHash::ToHexString(StringBuilderBase& outBuilder) const -{ - String_t Str; - ToHexString(Str); - - outBuilder.AppendRange(Str, &Str[StringLength]); - - return outBuilder; -} - -std::string -IoHash::ToHexString() const -{ - String_t Str; - ToHexString(Str); - - return Str; -} - -} // namespace zen |