[studio] Change output of Claw OC files to make them recognizable as test files
This commit is contained in:
@@ -18,9 +18,18 @@ static ox::Error convertFile(
|
|||||||
ox::ClawFormat const fmt) noexcept {
|
ox::ClawFormat const fmt) noexcept {
|
||||||
ox::Buffer buff;
|
ox::Buffer buff;
|
||||||
ox::ModelObject obj;
|
ox::ModelObject obj;
|
||||||
|
ox::UUID uuid;
|
||||||
OX_RETURN_ERROR(fs.read(path).moveTo(buff).reoriginate(1, "unable to read file"));
|
OX_RETURN_ERROR(fs.read(path).moveTo(buff).reoriginate(1, "unable to read file"));
|
||||||
|
OX_RETURN_ERROR(keel::readUuidHeader(buff).moveTo(uuid));
|
||||||
OX_RETURN_ERROR(keel::readAsset(ts, buff).moveTo(obj).reoriginate(1, "unable to parse file"));
|
OX_RETURN_ERROR(keel::readAsset(ts, buff).moveTo(obj).reoriginate(1, "unable to parse file"));
|
||||||
OX_RETURN_ERROR(ox::writeClaw(obj, fmt).moveTo(buff));
|
buff.clear();
|
||||||
|
ox::BufferWriter wrtr{&buff};
|
||||||
|
OX_RETURN_ERROR(keel::writeUuidHeader(wrtr, uuid));
|
||||||
|
OX_RETURN_ERROR(ox::writeClaw(obj, wrtr, fmt));
|
||||||
|
if (fmt == ox::ClawFormat::Organic) {
|
||||||
|
*buff.back().value = '\n';
|
||||||
|
}
|
||||||
|
OX_RETURN_ERROR(wrtr.write(buff.data(), buff.size()));
|
||||||
OX_RETURN_ERROR(fs.write(path, buff).reoriginate(1, "unable to write file"));
|
OX_RETURN_ERROR(fs.write(path, buff).reoriginate(1, "unable to write file"));
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
@@ -31,12 +40,12 @@ static void printUsage() noexcept {
|
|||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
static constexpr ox::Result<ox::ClawFormat> getFmt(ox::StringViewCR fmtStr) noexcept {
|
static constexpr ox::Result<ox::ClawFormat> getFmt(ox::StringViewCR fmtStr) noexcept {
|
||||||
if (fmtStr == "mc") {
|
if (caseInsensitiveEquals(fmtStr, "mc") == 0) {
|
||||||
return ox::ClawFormat::Metal;
|
return ox::ClawFormat::Metal;
|
||||||
} else if (fmtStr == "oc") {
|
} else if (caseInsensitiveEquals(fmtStr, "oc") == 0) {
|
||||||
return ox::ClawFormat::Organic;
|
return ox::ClawFormat::Organic;
|
||||||
}
|
}
|
||||||
return ox::Error(1, "invalid format");
|
return ox::Error{1, "invalid format"};
|
||||||
}
|
}
|
||||||
|
|
||||||
ox::Error cmdChangeFormat(Project &project, ox::SpanView<ox::CString> const args) noexcept {
|
ox::Error cmdChangeFormat(Project &project, ox::SpanView<ox::CString> const args) noexcept {
|
||||||
|
|||||||
@@ -165,7 +165,7 @@ template<typename T>
|
|||||||
ox::Error Project::writeObj(ox::StringViewCR path, T const &obj, ox::ClawFormat fmt) noexcept {
|
ox::Error Project::writeObj(ox::StringViewCR path, T const &obj, ox::ClawFormat fmt) noexcept {
|
||||||
OX_REQUIRE_M(buff, ox::writeClaw(obj, fmt));
|
OX_REQUIRE_M(buff, ox::writeClaw(obj, fmt));
|
||||||
if (fmt == ox::ClawFormat::Organic) {
|
if (fmt == ox::ClawFormat::Organic) {
|
||||||
buff.pop_back();
|
*buff.back().value = '\n';
|
||||||
}
|
}
|
||||||
// write to FS
|
// write to FS
|
||||||
OX_RETURN_ERROR(mkdir(parentDir(path)));
|
OX_RETURN_ERROR(mkdir(parentDir(path)));
|
||||||
|
|||||||
Reference in New Issue
Block a user