From f187c721df7de75083c7caf0aaa86c252caf06b8 Mon Sep 17 00:00:00 2001 From: Luis Michaelis Date: Wed, 6 Mar 2024 15:27:23 +0100 Subject: [PATCH] feat(Vfs): add `Vfs::save` API --- include/zenkit-capi/Vfs.h | 1 + src/Vfs.cc | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/include/zenkit-capi/Vfs.h b/include/zenkit-capi/Vfs.h index cd50b72..8486e68 100644 --- a/include/zenkit-capi/Vfs.h +++ b/include/zenkit-capi/Vfs.h @@ -26,6 +26,7 @@ typedef ZkBool (*ZkVfsNodeEnumerator)(void* ctx, ZkVfsNode const* node); ZKC_API ZkVfs* ZkVfs_new(void); ZKC_API void ZkVfs_del(ZkVfs* slf); +ZKC_API void ZkVfs_save(ZkVfs const* slf, ZkString path, ZkGameVersion version); ZKC_API ZkVfsNode const* ZkVfs_getRoot(ZkVfs const* slf); diff --git a/src/Vfs.cc b/src/Vfs.cc index f03d704..c56fd5e 100644 --- a/src/Vfs.cc +++ b/src/Vfs.cc @@ -14,6 +14,14 @@ void ZkVfs_del(ZkVfs* slf) { delete slf; } +void ZkVfs_save(ZkVfs const* slf, ZkString path, ZkGameVersion version) { + ZKC_TRACE_FN(); + ZKC_CHECK_NULLV(slf, path); + + auto wr = zenkit::Write::to(path); + slf->save(wr.get(), static_cast(version)); +} + ZkVfsNode const* ZkVfs_getRoot(ZkVfs const* slf) { ZKC_TRACE_FN(); ZKC_CHECK_NULL(slf);