2014-04-20 09:14:15 +00:00
|
|
|
#include "Athena/WiiSave.hpp"
|
|
|
|
#include "Athena/WiiFile.hpp"
|
|
|
|
#include "Athena/WiiBanner.hpp"
|
2015-03-01 20:42:39 +00:00
|
|
|
#include "Athena/MemoryReader.hpp"
|
|
|
|
#include "Athena/MemoryWriter.hpp"
|
2014-04-20 09:14:15 +00:00
|
|
|
#include "Athena/Utility.hpp"
|
2015-07-08 02:53:39 +00:00
|
|
|
#include "aes.hpp"
|
2013-02-16 04:22:16 +00:00
|
|
|
#include "ec.h"
|
|
|
|
#include "md5.h"
|
|
|
|
#include "sha1.h"
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <vector>
|
|
|
|
#include <string.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <iostream>
|
|
|
|
#include <iomanip>
|
|
|
|
|
|
|
|
|
2014-04-20 09:14:15 +00:00
|
|
|
namespace Athena
|
2013-07-21 03:57:20 +00:00
|
|
|
{
|
|
|
|
|
2013-02-16 04:22:16 +00:00
|
|
|
WiiSave::WiiSave()
|
2014-09-19 11:54:56 +00:00
|
|
|
: m_root(NULL),
|
|
|
|
m_banner(NULL)
|
|
|
|
|
2013-02-16 04:22:16 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
WiiSave::~WiiSave()
|
|
|
|
{
|
2014-09-19 11:54:56 +00:00
|
|
|
delete m_root;
|
2013-02-16 04:22:16 +00:00
|
|
|
delete m_banner;
|
|
|
|
m_banner = NULL;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-05-19 03:24:56 +00:00
|
|
|
void WiiSave::addFile(WiiFile* file)
|
2013-02-16 04:22:16 +00:00
|
|
|
{
|
2014-09-19 11:54:56 +00:00
|
|
|
m_root->addChild(file);
|
2013-02-16 04:22:16 +00:00
|
|
|
}
|
|
|
|
|
2014-09-19 11:54:56 +00:00
|
|
|
void WiiSave::setRoot(WiiFile* root)
|
2013-09-28 15:14:13 +00:00
|
|
|
{
|
2014-09-19 11:54:56 +00:00
|
|
|
if (root != m_root)
|
|
|
|
delete m_root;
|
2013-09-28 15:14:13 +00:00
|
|
|
|
2014-09-19 11:54:56 +00:00
|
|
|
m_root = root;
|
|
|
|
}
|
|
|
|
|
|
|
|
WiiFile* WiiSave::file(const std::string& filepath)
|
|
|
|
{
|
|
|
|
if (filepath.empty())
|
|
|
|
return nullptr;
|
2013-09-28 15:14:13 +00:00
|
|
|
|
2014-09-19 11:54:56 +00:00
|
|
|
std::string cleanPath(filepath);
|
2013-09-28 15:14:13 +00:00
|
|
|
|
2014-09-19 11:54:56 +00:00
|
|
|
while (cleanPath.at(0) == '/')
|
|
|
|
cleanPath.erase(cleanPath.begin());
|
2013-09-28 15:14:13 +00:00
|
|
|
|
2014-09-19 11:54:56 +00:00
|
|
|
return m_root->child(cleanPath);
|
2013-09-28 15:14:13 +00:00
|
|
|
}
|
|
|
|
|
2014-09-19 11:54:56 +00:00
|
|
|
atUint32 WiiSave::fileCount() const
|
2013-02-16 04:22:16 +00:00
|
|
|
{
|
2014-09-19 11:54:56 +00:00
|
|
|
return m_root->fileCount();
|
2013-02-16 04:22:16 +00:00
|
|
|
}
|
|
|
|
|
2014-09-19 11:54:56 +00:00
|
|
|
WiiFile* WiiSave::root()
|
2013-02-16 04:22:16 +00:00
|
|
|
{
|
2014-09-19 11:54:56 +00:00
|
|
|
return m_root;
|
2013-02-16 04:22:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void WiiSave::setBanner(WiiBanner* banner)
|
|
|
|
{
|
|
|
|
m_banner = banner;
|
|
|
|
}
|
|
|
|
|
|
|
|
WiiBanner* WiiSave::banner() const
|
|
|
|
{
|
|
|
|
return m_banner;
|
|
|
|
}
|
2013-07-21 03:57:20 +00:00
|
|
|
|
2015-05-19 03:24:56 +00:00
|
|
|
std::vector<WiiFile*> WiiSave::allFiles() const
|
2014-09-19 11:54:56 +00:00
|
|
|
{
|
|
|
|
return m_root->allChildren();
|
|
|
|
}
|
|
|
|
|
2013-07-21 03:57:20 +00:00
|
|
|
} // zelda
|