[keel,studio] Removing null terminator from JSON file output

This commit is contained in:
Gary Talent 2024-09-27 02:30:28 -05:00
parent 8b655c40b9
commit 5373b63cca
3 changed files with 6 additions and 8 deletions

View File

@ -76,8 +76,8 @@ static ox::Error pack(
oxReturnError(appendBinary(romBuff, dstBuff, *pl));
oxOutf("Final ROM buff size: {} bytes\n", romBuff.size());
oxReturnError(writeFileBuff(argRomBin, romBuff));
oxRequire(manifestJson, ox::writeOC(manifest));
oxReturnError(writeFileBuff(argManifest, manifestJson));
oxRequire(manifestJson, ox::writeOC<ox::String>(manifest));
oxReturnError(writeFileBuff(argManifest, {manifestJson.data(), manifestJson.len()}));
return {};
}

View File

@ -107,7 +107,7 @@ class Project {
void indexFile(ox::CRStringView path) noexcept;
ox::Error writeBuff(ox::CRStringView path, ox::Buffer const&buff) noexcept;
ox::Error writeBuff(ox::CRStringView path, ox::BufferView const&buff) noexcept;
ox::Result<ox::Buffer> loadBuff(ox::CRStringView path) const noexcept;

View File

@ -81,12 +81,10 @@ ox::Error Project::writeTypeStore() noexcept {
// write all descriptors because we don't know which types T depends on
oxReturnError(mkdir(m_typeDescPath));
for (auto const &t: m_typeStore.typeList()) {
oxRequireM(typeOut, ox::writeClaw(*t, ox::ClawFormat::Organic));
// replace garbage last character with new line
*typeOut.back().value = '\n';
oxRequire(typeOut, ox::writeClaw(*t, ox::ClawFormat::Organic));
// write to FS
auto const typePath = ox::sfmt("{}/{}", m_typeDescPath, buildTypeId(*t));
oxReturnError(writeBuff(typePath, typeOut));
oxReturnError(writeBuff(typePath, {typeOut.data(), typeOut.size() - 1}));
}
return {};
}
@ -114,7 +112,7 @@ void Project::indexFile(ox::CRStringView path) noexcept {
m_fileExtFileMap[ext].emplace_back(path);
}
ox::Error Project::writeBuff(ox::CRStringView path, ox::Buffer const&buff) noexcept {
ox::Error Project::writeBuff(ox::CRStringView path, ox::BufferView const&buff) noexcept {
constexpr auto HdrSz = 40;
ox::Buffer outBuff;
outBuff.reserve(buff.size() + HdrSz);