Athena IO Library
WiiFile.hpp
1 #ifndef WIIFILE_H
2 #define WIIFILE_H
3 
4 #include <string>
5 #include <map>
6 #include "athena/Global.hpp"
7 
8 namespace athena
9 {
10 
11 const atUint8 SD_KEY [16] = {0xab, 0x01, 0xb9, 0xd8, 0xe1, 0x62, 0x2b, 0x08, 0xaf, 0xba, 0xd8, 0x4d, 0xbf, 0xc2, 0xa5, 0x5d};
12 const atUint8 SD_IV [16] = {0x21, 0x67, 0x12, 0xe6, 0xaa, 0x1f, 0x68, 0x9f, 0x95, 0xc5, 0xa2, 0x23, 0x24, 0xdc, 0x6a, 0x98};
13 const atUint8 MD5_BLANKER[16] = {0x0e, 0x65, 0x37, 0x81, 0x99, 0xbe, 0x45, 0x17, 0xab, 0x06, 0xec, 0x22, 0x45, 0x1a, 0x57, 0x93};
14 
20 class WiiFile
21 {
22 public:
23 
29  {
30  OtherRead = 0x01,
31  OtherWrite = 0x02,
32  GroupRead = 0x04,
33  GroupWrite = 0x08,
34  OwnerRead = 0x10,
35  OwnerWrite = 0x20,
36 
37  // Mask values;
38  OtherRW = (OtherRead | OtherWrite),
39  GroupRW = (GroupRead | GroupWrite),
40  OwnerRW = (OwnerRead | OwnerWrite)
41  };
42 
46  enum Type
47  {
48  File = 0x01,
49  Directory = 0x02
50  };
51 
52  WiiFile();
53 
58  WiiFile(const std::string& filename);
59 
67  WiiFile(const std::string& filename, atUint8 permissions, const atUint8* data, atUint32 length);
68  virtual ~WiiFile();
69 
74  void setFilename(const std::string& filename);
75 
80  std::string filename() const;
81 
86  void setData(const atUint8* data);
91  atUint8* data() const;
92 
97  void setLength(const int len);
98 
103  int length() const;
104 
109  void setPermissions(const atUint8 permissions);
110 
115  atUint8 permissions() const;
116 
121  void setAttributes(const atUint8 attr);
122 
127  atUint8 attributes() const;
128 
133  void setType(Type type);
134 
139  Type type() const;
140 
145  bool isDirectory() const;
146 
151  bool isFile() const;
152 
157  void addChild(WiiFile* file);
162  std::vector<WiiFile*> children();
168  WiiFile* child(const std::string& name);
173  void removeChild(const std::string& name);
178  void removeChild(WiiFile* file);
179 
184  WiiFile* parent();
185 
190  void setParent(WiiFile* parent);
191 
196  atUint32 fileCount();
197 
202  std::vector<WiiFile*> allChildren();
203 
208  std::string fullpath();
209 protected:
210 private:
211  atUint8 m_permissions;
212  atUint8 m_attributes;
213  Type m_type;
214  std::string m_filename;
215  int m_fileLen;
216  atUint8* m_fileData;
217  WiiFile* m_parent;
218  std::vector<WiiFile*> m_children;
219 };
220 
221 } // zelda
222 #endif // WIIFILE_H
atUint8 * data() const
data
Wii file container class.
Definition: WiiFile.hpp:20
void removeChild(const std::string &name)
removeChild
Type type() const
type
int length() const
length
atUint32 fileCount()
fileCount
void setData(const atUint8 *data)
setData
WiiFile * parent()
parent
void setLength(const int len)
setLength
atUint8 permissions() const
permissions
bool isDirectory() const
isDirectory
std::vector< WiiFile * > children()
children
Type
The Type enum.
Definition: WiiFile.hpp:46
std::string fullpath()
fullpath
atUint8 attributes() const
attributes
void setType(Type type)
setType
Mask to get the Other group permissions.
Definition: WiiFile.hpp:38
bool isFile() const
isFile
Permission
The Wii uses a bastardized unix permissions system so these flags reflect the file&#39;s individual permi...
Definition: WiiFile.hpp:28
std::vector< WiiFile * > allChildren()
allChildren
void setParent(WiiFile *parent)
setParent
void setPermissions(const atUint8 permissions)
setPermissions
void addChild(WiiFile *file)
addChild
void setFilename(const std::string &filename)
setFilename
void setAttributes(const atUint8 attr)
setAttributes
std::string filename() const
filename
WiiFile * child(const std::string &name)
child