2016-03-04 23:00:12 +00:00
|
|
|
#include "athena/WiiSave.hpp"
|
|
|
|
#include "athena/WiiFile.hpp"
|
|
|
|
#include "athena/WiiBanner.hpp"
|
|
|
|
#include "athena/MemoryReader.hpp"
|
|
|
|
#include "athena/MemoryWriter.hpp"
|
|
|
|
#include "athena/Utility.hpp"
|
2013-02-16 04:22:16 +00:00
|
|
|
|
2017-12-29 07:55:42 +00:00
|
|
|
#include <cstdio>
|
2013-02-16 04:22:16 +00:00
|
|
|
#include <vector>
|
2017-12-29 07:55:42 +00:00
|
|
|
#include <cstring>
|
2013-02-16 04:22:16 +00:00
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <iostream>
|
|
|
|
#include <iomanip>
|
|
|
|
|
2018-12-08 05:18:17 +00:00
|
|
|
namespace athena {
|
2013-07-21 03:57:20 +00:00
|
|
|
|
2013-02-16 04:22:16 +00:00
|
|
|
WiiSave::WiiSave()
|
2018-12-08 05:18:17 +00:00
|
|
|
: m_root(NULL)
|
|
|
|
, m_banner(NULL)
|
2013-02-16 04:22:16 +00:00
|
|
|
|
2018-12-08 05:18:17 +00:00
|
|
|
{}
|
2013-02-16 04:22:16 +00:00
|
|
|
|
2018-12-08 05:18:17 +00:00
|
|
|
WiiSave::~WiiSave() {
|
|
|
|
delete m_root;
|
|
|
|
delete m_banner;
|
|
|
|
m_banner = NULL;
|
2013-02-16 04:22:16 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:18:17 +00:00
|
|
|
void WiiSave::addFile(WiiFile* file) { m_root->addChild(file); }
|
2013-02-16 04:22:16 +00:00
|
|
|
|
2018-12-08 05:18:17 +00:00
|
|
|
void WiiSave::setRoot(WiiFile* root) {
|
|
|
|
if (root != m_root)
|
|
|
|
delete m_root;
|
2013-09-28 15:14:13 +00:00
|
|
|
|
2018-12-08 05:18:17 +00:00
|
|
|
m_root = root;
|
2014-09-19 11:54:56 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:18:17 +00:00
|
|
|
WiiFile* WiiSave::file(const std::string& filepath) {
|
|
|
|
if (filepath.empty())
|
|
|
|
return nullptr;
|
2013-09-28 15:14:13 +00:00
|
|
|
|
2018-12-08 05:18:17 +00:00
|
|
|
std::string cleanPath(filepath);
|
2013-09-28 15:14:13 +00:00
|
|
|
|
2018-12-08 05:18:17 +00:00
|
|
|
while (cleanPath.at(0) == '/')
|
|
|
|
cleanPath.erase(cleanPath.begin());
|
2013-09-28 15:14:13 +00:00
|
|
|
|
2018-12-08 05:18:17 +00:00
|
|
|
return m_root->child(cleanPath);
|
2013-09-28 15:14:13 +00:00
|
|
|
}
|
|
|
|
|
2018-12-08 05:18:17 +00:00
|
|
|
atUint32 WiiSave::fileCount() const { return m_root->fileCount(); }
|
2013-02-16 04:22:16 +00:00
|
|
|
|
2018-12-08 05:18:17 +00:00
|
|
|
WiiFile* WiiSave::root() { return m_root; }
|
2013-02-16 04:22:16 +00:00
|
|
|
|
2018-12-08 05:18:17 +00:00
|
|
|
void WiiSave::setBanner(WiiBanner* banner) { m_banner = banner; }
|
2013-02-16 04:22:16 +00:00
|
|
|
|
2018-12-08 05:18:17 +00:00
|
|
|
WiiBanner* WiiSave::banner() const { return m_banner; }
|
2013-07-21 03:57:20 +00:00
|
|
|
|
2018-12-08 05:18:17 +00:00
|
|
|
std::vector<WiiFile*> WiiSave::allFiles() const { return m_root->allChildren(); }
|
2014-09-19 11:54:56 +00:00
|
|
|
|
2018-12-08 05:18:17 +00:00
|
|
|
} // namespace athena
|