[keel,studio] Add Make Copy option to ProjectExplorer
All checks were successful
Build / build (push) Successful in 3m46s

This commit is contained in:
2025-02-03 02:01:40 -06:00
parent 0abadc1850
commit 671dd86206
11 changed files with 153 additions and 3 deletions

View File

@ -15,6 +15,8 @@ constexpr auto K1HdrSz = 40;
ox::Result<ox::UUID> readUuidHeader(ox::BufferView buff) noexcept;
ox::Result<ox::UUID> regenerateUuidHeader(ox::Buffer &buff) noexcept;
ox::Error writeUuidHeader(ox::Writer_c auto &writer, ox::UUID const&uuid) noexcept {
OX_RETURN_ERROR(write(writer, "K1;"));
OX_RETURN_ERROR(uuid.toString(writer));

View File

@ -8,15 +8,25 @@ namespace keel {
ox::Result<ox::UUID> readUuidHeader(ox::BufferView buff) noexcept {
if (buff.size() < K1HdrSz) [[unlikely]] {
return ox::Error(1, "Insufficient data to contain complete Keel header");
return ox::Error{1, "Insufficient data to contain complete Keel header"};
}
constexpr ox::StringView k1Hdr = "K1;";
if (k1Hdr != ox::StringView(buff.data(), k1Hdr.bytes())) [[unlikely]] {
return ox::Error(2, "No Keel asset header data");
if (k1Hdr != ox::StringView{buff.data(), k1Hdr.bytes()}) [[unlikely]] {
return ox::Error{2, "No Keel asset header data"};
}
return ox::UUID::fromString(ox::StringView(&buff[k1Hdr.bytes()], 36));
}
ox::Result<ox::UUID> regenerateUuidHeader(ox::Buffer &buff) noexcept {
OX_RETURN_ERROR(readUuidHeader(buff));
OX_REQUIRE(id, ox::UUID::generate());
auto const str = id.toString();
for (size_t i = 0; i < ox::UUIDStr::cap(); ++i) {
buff[i + 3] = str[i];
}
return id;
}
ox::Result<ox::ModelObject> readAsset(ox::TypeStore &ts, ox::BufferView buff) noexcept {
std::size_t offset = 0;
if (!readUuidHeader(buff).error) {