2014-04-20 09:14:15 +00:00
|
|
|
// This file is part of libAthena.
|
2013-02-16 18:28:30 +00:00
|
|
|
//
|
2014-04-20 09:14:15 +00:00
|
|
|
// libAthena is free software: you can redistribute it and/or modify
|
2013-02-16 18:28:30 +00:00
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
2014-04-20 09:14:15 +00:00
|
|
|
// libAthena is distributed in the hope that it will be useful,
|
2013-02-16 18:28:30 +00:00
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
2014-04-20 09:14:15 +00:00
|
|
|
// along with libAthena. If not, see <http://www.gnu.org/licenses/>
|
|
|
|
|
|
|
|
#include "Athena/WiiSave.hpp"
|
|
|
|
#include "Athena/WiiFile.hpp"
|
|
|
|
#include "Athena/WiiBanner.hpp"
|
|
|
|
#include "Athena/BinaryReader.hpp"
|
|
|
|
#include "Athena/BinaryWriter.hpp"
|
|
|
|
#include "Athena/Utility.hpp"
|
2013-02-16 04:22:16 +00:00
|
|
|
#include "aes.h"
|
|
|
|
#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()
|
|
|
|
: m_banner(NULL)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
WiiSave::~WiiSave()
|
|
|
|
{
|
|
|
|
m_files.clear();
|
|
|
|
|
|
|
|
delete m_banner;
|
|
|
|
m_banner = NULL;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void WiiSave::addFile(const std::string& filepath, WiiFile* file)
|
|
|
|
{
|
|
|
|
m_files[filepath] = file;
|
|
|
|
}
|
|
|
|
|
2013-09-28 15:14:13 +00:00
|
|
|
void WiiSave::setFiles(std::unordered_map<std::string, WiiFile*> files)
|
|
|
|
{
|
|
|
|
if (files.size() <= 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
std::cout << "Setting file map...";
|
|
|
|
if (m_files.size() > 0)
|
|
|
|
{
|
|
|
|
std::unordered_map<std::string, WiiFile*>::iterator iter = m_files.begin();
|
|
|
|
|
|
|
|
for (;iter != m_files.end(); ++iter)
|
|
|
|
{
|
|
|
|
if (iter->second)
|
|
|
|
delete iter->second;
|
|
|
|
}
|
|
|
|
|
|
|
|
m_files.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
m_files = files;
|
|
|
|
std::cout << "done" << std::endl;
|
|
|
|
}
|
|
|
|
|
2013-02-16 04:22:16 +00:00
|
|
|
WiiFile* WiiSave::file(const std::string& filepath) const
|
|
|
|
{
|
|
|
|
std::unordered_map<std::string, WiiFile*>::const_iterator iter = m_files.begin();
|
|
|
|
|
|
|
|
for (;iter != m_files.end(); ++iter)
|
|
|
|
{
|
|
|
|
if (iter->first == filepath)
|
|
|
|
return (WiiFile*)iter->second;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::unordered_map<std::string, WiiFile*>& WiiSave::fileList()
|
|
|
|
{
|
|
|
|
return m_files;
|
|
|
|
}
|
|
|
|
|
|
|
|
void WiiSave::setBanner(WiiBanner* banner)
|
|
|
|
{
|
|
|
|
m_banner = banner;
|
|
|
|
}
|
|
|
|
|
|
|
|
WiiBanner* WiiSave::banner() const
|
|
|
|
{
|
|
|
|
return m_banner;
|
|
|
|
}
|
2013-07-21 03:57:20 +00:00
|
|
|
|
|
|
|
} // zelda
|