Validate PPI project layout

This commit is contained in:
2026-06-01 12:38:21 +02:00
parent 37854ea8b9
commit 2da247f0fb
9 changed files with 146 additions and 21 deletions

View File

@@ -287,22 +287,25 @@ int inspect_project(int argc, char** argv)
std::istreambuf_iterator<char>()
};
const auto* data = reinterpret_cast<const std::byte*>(chars.data());
const auto header = pp::assets::parse_ppi_header(std::span<const std::byte>(data, chars.size()));
if (!header) {
print_error("inspect-project", header.status().message);
const auto layout = pp::assets::parse_ppi_project_layout(std::span<const std::byte>(data, chars.size()));
if (!layout) {
print_error("inspect-project", layout.status().message);
return 2;
}
std::cout << "{\"ok\":true,\"command\":\"inspect-project\""
<< ",\"documentVersion\":\"" << header.value().document_version.major
<< "." << header.value().document_version.minor << "\""
<< ",\"softwareVersion\":\"" << header.value().software_version.major
<< "." << header.value().software_version.minor
<< "." << header.value().software_version.fix
<< "." << header.value().software_version.build << "\""
<< ",\"thumbnail\":{\"width\":" << header.value().thumbnail.width
<< ",\"height\":" << header.value().thumbnail.height
<< ",\"components\":" << header.value().thumbnail.components
<< ",\"documentVersion\":\"" << layout.value().header.document_version.major
<< "." << layout.value().header.document_version.minor << "\""
<< ",\"softwareVersion\":\"" << layout.value().header.software_version.major
<< "." << layout.value().header.software_version.minor
<< "." << layout.value().header.software_version.fix
<< "." << layout.value().header.software_version.build << "\""
<< ",\"thumbnail\":{\"width\":" << layout.value().header.thumbnail.width
<< ",\"height\":" << layout.value().header.thumbnail.height
<< ",\"components\":" << layout.value().header.thumbnail.components
<< ",\"bytes\":" << layout.value().thumbnail_bytes
<< "},\"body\":{\"offset\":" << layout.value().body_offset
<< ",\"bytes\":" << layout.value().body_bytes
<< "}}\n";
return 0;
}