athena/include/WiiFile.hpp

175 lines
3.6 KiB
C++
Raw Normal View History

// This file is part of libZelda.
//
// libZelda is free software: you can redistribute it and/or modify
// 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.
//
// libZelda is distributed in the hope that it will be useful,
// 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
// along with libZelda. If not, see <http://www.gnu.org/licenses/>
2013-02-16 04:22:16 +00:00
#ifndef WIIFILE_H
#define WIIFILE_H
#include <string>
#include <map>
#include <Types.hpp>
2013-07-21 03:57:20 +00:00
namespace zelda
{
/*! \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;
2013-07-21 03:57:20 +00:00
OtherRW = (OtherRead|OtherWrite), //!< Mask to get the Other group permissions
2013-02-16 04:22:16 +00:00
GroupRW = (GroupRead|GroupWrite),
OwnerRW = (OwnerRead|OwnerWrite)
};
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
*/
2013-02-16 04:22:16 +00:00
WiiFile(const std::string& filename, Uint8 permissions, const Uint8* data, Uint32 length);
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
*/
2013-02-16 04:22:16 +00:00
void setData(const Uint8* data);
2013-07-21 03:57:20 +00:00
/*!
* \brief data
* \return
*/
Uint8* 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
*/
2013-02-16 04:22:16 +00:00
void setPermissions(const Uint8 permissions);
2013-07-21 03:57:20 +00:00
/*!
* \brief permissions
* \return
*/
2013-02-16 04:22:16 +00:00
Uint8 permissions() const;
2013-07-21 03:57:20 +00:00
/*!
* \brief setAttributes
* \param attr
*/
2013-02-16 04:22:16 +00:00
void setAttributes(const Uint8 attr);
2013-07-21 03:57:20 +00:00
/*!
* \brief attributes
* \return
*/
2013-02-16 04:22:16 +00:00
Uint8 attributes() const;
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;
protected:
private:
Uint8 m_permissions;
Uint8 m_attributes;
Type m_type;
std::string m_filename;
int m_fileLen;
Uint8* m_fileData;
};
2013-07-21 03:57:20 +00:00
} // zelda
2013-02-16 04:22:16 +00:00
#endif // WIIFILE_H