2016-04-12 10:52:40 +00:00
|
|
|
#include "athena/IStreamReader.hpp"
|
|
|
|
#include "athena/IStreamWriter.hpp"
|
|
|
|
#include "athena/FileWriter.hpp"
|
|
|
|
#include "DGRP.hpp"
|
|
|
|
|
2017-12-29 08:08:12 +00:00
|
|
|
namespace DataSpec::DNADGRP
|
2016-04-12 11:37:07 +00:00
|
|
|
{
|
2016-04-12 10:52:40 +00:00
|
|
|
|
|
|
|
template <class IDType>
|
|
|
|
bool ExtractDGRP(PAKEntryReadStream& rs, const hecl::ProjectPath& outPath)
|
|
|
|
{
|
2016-08-22 03:47:48 +00:00
|
|
|
athena::io::FileWriter writer(outPath.getAbsolutePath());
|
|
|
|
if (writer.isOpen())
|
2016-04-12 10:52:40 +00:00
|
|
|
{
|
|
|
|
DGRP<IDType> dgrp;
|
|
|
|
dgrp.read(rs);
|
2018-02-22 07:24:51 +00:00
|
|
|
athena::io::ToYAMLStream(dgrp, writer);
|
2016-04-12 10:52:40 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
template bool ExtractDGRP<UniqueID32>(PAKEntryReadStream& rs, const hecl::ProjectPath& outPath);
|
|
|
|
template bool ExtractDGRP<UniqueID64>(PAKEntryReadStream& rs, const hecl::ProjectPath& outPath);
|
|
|
|
|
|
|
|
template <class IDType>
|
|
|
|
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)
|
2017-10-22 06:11:22 +00:00
|
|
|
w.writeUByte(0xff);
|
2016-04-12 10:52:40 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
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
|
|
|
|
2016-04-12 11:37:07 +00:00
|
|
|
}
|