2013-02-16 04:22:16 +00:00
|
|
|
#ifndef WIIFILE_H
|
|
|
|
#define WIIFILE_H
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <map>
|
2014-04-20 09:14:15 +00:00
|
|
|
#include "Athena/Global.hpp"
|
2013-02-16 04:22:16 +00:00
|
|
|
|
2014-04-20 09:14:15 +00:00
|
|
|
namespace Athena
|
2013-07-21 03:57:20 +00:00
|
|
|
{
|
|
|
|
|
2014-06-18 04:51:18 +00:00
|
|
|
const atUint8 SD_KEY [16] = {0xab, 0x01, 0xb9, 0xd8, 0xe1, 0x62, 0x2b, 0x08, 0xaf, 0xba, 0xd8, 0x4d, 0xbf, 0xc2, 0xa5, 0x5d};
|
|
|
|
const atUint8 SD_IV [16] = {0x21, 0x67, 0x12, 0xe6, 0xaa, 0x1f, 0x68, 0x9f, 0x95, 0xc5, 0xa2, 0x23, 0x24, 0xdc, 0x6a, 0x98};
|
|
|
|
const atUint8 MD5_BLANKER[16] = {0x0e, 0x65, 0x37, 0x81, 0x99, 0xbe, 0x45, 0x17, 0xab, 0x06, 0xec, 0x22, 0x45, 0x1a, 0x57, 0x93};
|
2014-04-20 09:14:15 +00:00
|
|
|
|
2013-07-21 03:57:20 +00:00
|
|
|
/*! \class WiiFile
|
|
|
|
* \brief Wii file container class
|
|
|
|
*
|
|
|
|
* Contains all relevant data for a file in a data.bin file.
|
|
|
|
*/
|
2013-02-16 04:22:16 +00:00
|
|
|
class WiiFile
|
|
|
|
{
|
|
|
|
public:
|
2013-07-21 03:57:20 +00:00
|
|
|
|
|
|
|
/*! \enum Permission
|
|
|
|
* \brief The Wii uses a bastardized unix permissions system so these flags
|
|
|
|
* reflect the file's individual permissions.
|
|
|
|
*/
|
2013-02-16 04:22:16 +00:00
|
|
|
enum Permission
|
|
|
|
{
|
|
|
|
OtherRead = 0x01,
|
|
|
|
OtherWrite = 0x02,
|
|
|
|
GroupRead = 0x04,
|
|
|
|
GroupWrite = 0x08,
|
|
|
|
OwnerRead = 0x10,
|
|
|
|
OwnerWrite = 0x20,
|
|
|
|
|
|
|
|
// Mask values;
|
2015-05-19 03:24:56 +00:00
|
|
|
OtherRW = (OtherRead | OtherWrite), //!< Mask to get the Other group permissions
|
|
|
|
GroupRW = (GroupRead | GroupWrite),
|
|
|
|
OwnerRW = (OwnerRead | OwnerWrite)
|
2013-02-16 04:22:16 +00:00
|
|
|
};
|
|
|
|
|
2013-07-21 03:57:20 +00:00
|
|
|
/*!
|
|
|
|
* \brief The Type enum
|
|
|
|
*/
|
2013-02-16 04:22:16 +00:00
|
|
|
enum Type
|
|
|
|
{
|
|
|
|
File = 0x01,
|
|
|
|
Directory = 0x02
|
|
|
|
};
|
|
|
|
|
|
|
|
WiiFile();
|
2013-07-21 03:57:20 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief WiiFile
|
|
|
|
* \param filename
|
|
|
|
*/
|
2013-02-16 04:22:16 +00:00
|
|
|
WiiFile(const std::string& filename);
|
2013-07-21 03:57:20 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief WiiFile
|
|
|
|
* \param filename
|
|
|
|
* \param permissions
|
|
|
|
* \param data
|
|
|
|
* \param length
|
|
|
|
*/
|
2014-06-18 04:51:18 +00:00
|
|
|
WiiFile(const std::string& filename, atUint8 permissions, const atUint8* data, atUint32 length);
|
2013-02-16 04:22:16 +00:00
|
|
|
virtual ~WiiFile();
|
|
|
|
|
2013-07-21 03:57:20 +00:00
|
|
|
/*!
|
|
|
|
* \brief setFilename
|
|
|
|
* \param filename
|
|
|
|
*/
|
2013-02-16 04:22:16 +00:00
|
|
|
void setFilename(const std::string& filename);
|
2013-07-21 03:57:20 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief filename
|
|
|
|
* \return
|
|
|
|
*/
|
2013-02-16 04:22:16 +00:00
|
|
|
std::string filename() const;
|
|
|
|
|
2013-07-21 03:57:20 +00:00
|
|
|
/*!
|
|
|
|
* \brief setData
|
|
|
|
* \param data
|
|
|
|
*/
|
2014-06-18 04:51:18 +00:00
|
|
|
void setData(const atUint8* data);
|
2013-07-21 03:57:20 +00:00
|
|
|
/*!
|
|
|
|
* \brief data
|
|
|
|
* \return
|
|
|
|
*/
|
2014-06-18 04:51:18 +00:00
|
|
|
atUint8* data() const;
|
2013-02-16 04:22:16 +00:00
|
|
|
|
2013-07-21 03:57:20 +00:00
|
|
|
/*!
|
|
|
|
* \brief setLength
|
|
|
|
* \param len
|
|
|
|
*/
|
2013-02-16 04:22:16 +00:00
|
|
|
void setLength(const int len);
|
|
|
|
|
2013-07-21 03:57:20 +00:00
|
|
|
/*!
|
|
|
|
* \brief length
|
|
|
|
* \return
|
|
|
|
*/
|
|
|
|
int length() const;
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief setPermissions
|
|
|
|
* \param permissions
|
|
|
|
*/
|
2014-06-18 04:51:18 +00:00
|
|
|
void setPermissions(const atUint8 permissions);
|
2013-07-21 03:57:20 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief permissions
|
|
|
|
* \return
|
|
|
|
*/
|
2014-06-18 04:51:18 +00:00
|
|
|
atUint8 permissions() const;
|
2013-02-16 04:22:16 +00:00
|
|
|
|
2013-07-21 03:57:20 +00:00
|
|
|
/*!
|
|
|
|
* \brief setAttributes
|
|
|
|
* \param attr
|
|
|
|
*/
|
2014-06-18 04:51:18 +00:00
|
|
|
void setAttributes(const atUint8 attr);
|
2013-07-21 03:57:20 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief attributes
|
|
|
|
* \return
|
|
|
|
*/
|
2014-06-18 04:51:18 +00:00
|
|
|
atUint8 attributes() const;
|
2013-02-16 04:22:16 +00:00
|
|
|
|
2013-07-21 03:57:20 +00:00
|
|
|
/*!
|
|
|
|
* \brief setType
|
|
|
|
* \param type
|
|
|
|
*/
|
2013-02-16 04:22:16 +00:00
|
|
|
void setType(Type type);
|
2013-07-21 03:57:20 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief type
|
|
|
|
* \return
|
|
|
|
*/
|
2013-02-16 04:22:16 +00:00
|
|
|
Type type() const;
|
|
|
|
|
2013-07-21 03:57:20 +00:00
|
|
|
/*!
|
|
|
|
* \brief isDirectory
|
|
|
|
* \return
|
|
|
|
*/
|
2013-02-16 04:22:16 +00:00
|
|
|
bool isDirectory() const;
|
2013-07-21 03:57:20 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief isFile
|
|
|
|
* \return
|
|
|
|
*/
|
2013-02-16 04:22:16 +00:00
|
|
|
bool isFile() const;
|
|
|
|
|
2015-05-21 04:57:27 +00:00
|
|
|
/*!
|
|
|
|
* \brief addChild
|
|
|
|
* \param file
|
|
|
|
*/
|
2014-09-19 11:54:56 +00:00
|
|
|
void addChild(WiiFile* file);
|
2015-05-21 04:57:27 +00:00
|
|
|
/*!
|
|
|
|
* \brief children
|
|
|
|
* \return
|
|
|
|
*/
|
2014-09-19 11:54:56 +00:00
|
|
|
std::vector<WiiFile*> children();
|
2015-05-21 04:57:27 +00:00
|
|
|
/*!
|
|
|
|
* \brief child
|
|
|
|
* \param name
|
|
|
|
* \return
|
|
|
|
*/
|
2014-09-19 11:54:56 +00:00
|
|
|
WiiFile* child(const std::string& name);
|
2015-05-21 04:57:27 +00:00
|
|
|
/*!
|
|
|
|
* \brief removeChild
|
|
|
|
* \param name
|
|
|
|
*/
|
2014-09-19 11:54:56 +00:00
|
|
|
void removeChild(const std::string& name);
|
2015-05-21 04:57:27 +00:00
|
|
|
/*!
|
|
|
|
* \brief removeChild
|
|
|
|
* \param file
|
|
|
|
*/
|
2014-09-19 11:54:56 +00:00
|
|
|
void removeChild(WiiFile* file);
|
|
|
|
|
2015-05-21 04:57:27 +00:00
|
|
|
/*!
|
|
|
|
* \brief parent
|
|
|
|
* \return
|
|
|
|
*/
|
2014-09-19 11:54:56 +00:00
|
|
|
WiiFile* parent();
|
2015-05-21 04:57:27 +00:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief setParent
|
|
|
|
* \param parent
|
|
|
|
*/
|
2015-05-19 03:24:56 +00:00
|
|
|
void setParent(WiiFile* parent);
|
2014-09-19 11:54:56 +00:00
|
|
|
|
2015-05-21 04:57:27 +00:00
|
|
|
/*!
|
|
|
|
* \brief fileCount
|
|
|
|
* \return
|
|
|
|
*/
|
2014-09-19 11:54:56 +00:00
|
|
|
atUint32 fileCount();
|
|
|
|
|
2015-05-21 04:57:27 +00:00
|
|
|
/*!
|
|
|
|
* \brief allChildren
|
|
|
|
* \return
|
|
|
|
*/
|
2014-09-19 11:54:56 +00:00
|
|
|
std::vector<WiiFile*> allChildren();
|
|
|
|
|
2015-05-21 04:57:27 +00:00
|
|
|
/*!
|
|
|
|
* \brief fullpath
|
|
|
|
* \return
|
|
|
|
*/
|
2014-09-19 11:54:56 +00:00
|
|
|
std::string fullpath();
|
2013-02-16 04:22:16 +00:00
|
|
|
protected:
|
|
|
|
private:
|
2014-06-18 04:51:18 +00:00
|
|
|
atUint8 m_permissions;
|
|
|
|
atUint8 m_attributes;
|
2014-09-19 11:54:56 +00:00
|
|
|
Type m_type;
|
|
|
|
std::string m_filename;
|
|
|
|
int m_fileLen;
|
2014-06-18 04:51:18 +00:00
|
|
|
atUint8* m_fileData;
|
2014-09-19 11:54:56 +00:00
|
|
|
WiiFile* m_parent;
|
|
|
|
std::vector<WiiFile*> m_children;
|
2013-02-16 04:22:16 +00:00
|
|
|
};
|
|
|
|
|
2013-07-21 03:57:20 +00:00
|
|
|
} // zelda
|
2013-02-16 04:22:16 +00:00
|
|
|
#endif // WIIFILE_H
|