diff options
Diffstat (limited to 'src/zencore/compactbinaryfile.cpp')
| -rw-r--r-- | src/zencore/compactbinaryfile.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/zencore/compactbinaryfile.cpp b/src/zencore/compactbinaryfile.cpp index ec2fc3cd5..9ddafbe15 100644 --- a/src/zencore/compactbinaryfile.cpp +++ b/src/zencore/compactbinaryfile.cpp @@ -30,4 +30,15 @@ LoadCompactBinaryObject(const std::filesystem::path& FilePath) return {.Hash = IoHash::Zero}; } +void +WriteCompactBinaryObject(const std::filesystem::path& Path, const CbObject& Object) +{ + // We cannot use CbObject::GetView() here because it may not return a complete + // view since the type byte can be omitted in arrays. + CbWriter Writer; + Writer.AddObject(Object); + CbFieldIterator Fields = Writer.Save(); + zen::WriteFile(Path, IoBufferBuilder::MakeFromMemory(Fields.GetRangeView())); +} + } // namespace zen |