From c47f48eba707ef796ef17031e0078f1d65cd62fc Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Wed, 22 May 2024 00:32:49 -0500 Subject: [PATCH] [keel] Add/cleanup UUID/path lookup functions --- src/olympic/keel/include/keel/media.hpp | 8 ++++++-- src/olympic/keel/src/media.cpp | 18 ++++++++++++++---- src/olympic/keel/src/pack.cpp | 2 +- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/olympic/keel/include/keel/media.hpp b/src/olympic/keel/include/keel/media.hpp index 5c20f34c..84912bbd 100644 --- a/src/olympic/keel/include/keel/media.hpp +++ b/src/olympic/keel/include/keel/media.hpp @@ -93,9 +93,13 @@ void createUuidMapping(Context &ctx, ox::StringView filePath, ox::UUID const&uui ox::Error buildUuidMap(Context &ctx) noexcept; -ox::Result uuidToPath(Context &ctx, ox::CRStringView uuid) noexcept; +ox::Result pathToUuid(Context &ctx, ox::CRStringView path) noexcept; -ox::Result uuidToPath(Context &ctx, ox::UUID const&uuid) noexcept; +ox::Result uuidUrlToPath(Context &ctx, ox::StringView uuid) noexcept; + +ox::Result uuidToPath(Context &ctx, ox::CRStringView uuid) noexcept; + +ox::Result uuidToPath(Context &ctx, ox::UUID const&uuid) noexcept; ox::Error performPackTransforms(Context &ctx, ox::Buffer &clawData) noexcept; diff --git a/src/olympic/keel/src/media.cpp b/src/olympic/keel/src/media.cpp index 4fffc643..679484fa 100644 --- a/src/olympic/keel/src/media.cpp +++ b/src/olympic/keel/src/media.cpp @@ -83,19 +83,29 @@ ox::Result pathToUuid(Context &ctx, ox::CRStringView path) noexcept { #endif } -ox::Result uuidToPath(Context &ctx, ox::CRStringView uuid) noexcept { +ox::Result uuidUrlToPath(Context &ctx, ox::StringView uuid) noexcept { + uuid = substr(uuid, 7); #ifndef OX_BARE_METAL oxRequireM(out, ctx.uuidToPath.at(uuid)); - return std::move(*out); + return ox::CStringView(*out); #else return OxError(1, "UUID to path conversion not supported on this platform"); #endif } -ox::Result uuidToPath(Context &ctx, ox::UUID const&uuid) noexcept { +ox::Result uuidToPath(Context &ctx, ox::CRStringView uuid) noexcept { +#ifndef OX_BARE_METAL + oxRequireM(out, ctx.uuidToPath.at(uuid)); + return ox::CStringView(*out); +#else + return OxError(1, "UUID to path conversion not supported on this platform"); +#endif +} + +ox::Result uuidToPath(Context &ctx, ox::UUID const&uuid) noexcept { #ifndef OX_BARE_METAL oxRequireM(out, ctx.uuidToPath.at(uuid.toString())); - return std::move(*out); + return ox::CStringView(*out); #else return OxError(1, "UUID to path conversion not supported on this platform"); #endif diff --git a/src/olympic/keel/src/pack.cpp b/src/olympic/keel/src/pack.cpp index b94e3645..e79a9242 100644 --- a/src/olympic/keel/src/pack.cpp +++ b/src/olympic/keel/src/pack.cpp @@ -30,7 +30,7 @@ static ox::Error pathToInode( } if (beginsWith(path, "uuid://")) { auto const uuid = ox::substr(path, 7); - oxReturnError(keel::uuidToPath(ctx, uuid).moveTo(path)); + oxReturnError(keel::uuidToPath(ctx, uuid).to().moveTo(path)); } oxRequire(s, dest.stat(path)); oxReturnError(o.at("type").unwrap()->set(static_cast(ox::FileAddressType::Inode)));