metaforce/DataSpec/DNACommon/DGRP.cpp

38 lines
1.2 KiB
C++
Raw Normal View History

2016-04-12 10:52:40 +00:00
#include "athena/IStreamReader.hpp"
#include "athena/IStreamWriter.hpp"
#include "athena/FileWriter.hpp"
#include "DGRP.hpp"
2018-12-08 05:30:43 +00:00
namespace DataSpec::DNADGRP {
2016-04-12 10:52:40 +00:00
template <class IDType>
2018-12-08 05:30:43 +00:00
bool ExtractDGRP(PAKEntryReadStream& rs, const hecl::ProjectPath& outPath) {
athena::io::FileWriter writer(outPath.getAbsolutePath());
if (writer.isOpen()) {
DGRP<IDType> dgrp;
dgrp.read(rs);
athena::io::ToYAMLStream(dgrp, writer);
return true;
}
return false;
2016-04-12 10:52:40 +00:00
}
template bool ExtractDGRP<UniqueID32>(PAKEntryReadStream& rs, const hecl::ProjectPath& outPath);
template bool ExtractDGRP<UniqueID64>(PAKEntryReadStream& rs, const hecl::ProjectPath& outPath);
template <class IDType>
2018-12-08 05:30:43 +00:00
bool WriteDGRP(const DGRP<IDType>& dgrp, const hecl::ProjectPath& outPath) {
athena::io::FileWriter w(outPath.getAbsolutePath(), true, false);
if (w.hasError())
return false;
dgrp.write(w);
int64_t rem = w.position() % 32;
if (rem)
for (int64_t i = 0; i < 32 - rem; ++i)
w.writeUByte(0xff);
return true;
2016-04-12 10:52:40 +00:00
}
template bool WriteDGRP<UniqueID32>(const DGRP<UniqueID32>& dgrp, const hecl::ProjectPath& outPath);
template bool WriteDGRP<UniqueID64>(const DGRP<UniqueID64>& dgrp, const hecl::ProjectPath& outPath);
2018-02-22 07:24:51 +00:00
2018-12-08 05:30:43 +00:00
} // namespace DataSpec::DNADGRP