Athena IO Library
WiiFile.hpp
1 #ifndef ATHENA_NO_SAVES
2 // This file is part of libAthena.
3 //
4 // libAthena is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // libAthena is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with libAthena. If not, see <http://www.gnu.org/licenses/>
16 
17 #ifndef WIIFILE_H
18 #define WIIFILE_H
19 
20 #include <string>
21 #include <map>
22 #include "Athena/Global.hpp"
23 
24 namespace Athena
25 {
26 
27 const atUint8 SD_KEY [16] = {0xab, 0x01, 0xb9, 0xd8, 0xe1, 0x62, 0x2b, 0x08, 0xaf, 0xba, 0xd8, 0x4d, 0xbf, 0xc2, 0xa5, 0x5d};
28 const atUint8 SD_IV [16] = {0x21, 0x67, 0x12, 0xe6, 0xaa, 0x1f, 0x68, 0x9f, 0x95, 0xc5, 0xa2, 0x23, 0x24, 0xdc, 0x6a, 0x98};
29 const atUint8 MD5_BLANKER[16] = {0x0e, 0x65, 0x37, 0x81, 0x99, 0xbe, 0x45, 0x17, 0xab, 0x06, 0xec, 0x22, 0x45, 0x1a, 0x57, 0x93};
30 
36 class WiiFile
37 {
38 public:
39 
45  {
46  OtherRead = 0x01,
47  OtherWrite = 0x02,
48  GroupRead = 0x04,
49  GroupWrite = 0x08,
50  OwnerRead = 0x10,
51  OwnerWrite = 0x20,
52 
53  // Mask values;
54  OtherRW = (OtherRead | OtherWrite),
55  GroupRW = (GroupRead | GroupWrite),
56  OwnerRW = (OwnerRead | OwnerWrite)
57  };
58 
62  enum Type
63  {
64  File = 0x01,
65  Directory = 0x02
66  };
67 
68  WiiFile();
69 
74  WiiFile(const std::string& filename);
75 
83  WiiFile(const std::string& filename, atUint8 permissions, const atUint8* data, atUint32 length);
84  virtual ~WiiFile();
85 
90  void setFilename(const std::string& filename);
91 
96  std::string filename() const;
97 
102  void setData(const atUint8* data);
107  atUint8* data() const;
108 
113  void setLength(const int len);
114 
119  int length() const;
120 
125  void setPermissions(const atUint8 permissions);
126 
131  atUint8 permissions() const;
132 
137  void setAttributes(const atUint8 attr);
138 
143  atUint8 attributes() const;
144 
149  void setType(Type type);
150 
155  Type type() const;
156 
161  bool isDirectory() const;
162 
167  bool isFile() const;
168 
173  void addChild(WiiFile* file);
178  std::vector<WiiFile*> children();
184  WiiFile* child(const std::string& name);
189  void removeChild(const std::string& name);
194  void removeChild(WiiFile* file);
195 
200  WiiFile* parent();
201 
206  void setParent(WiiFile* parent);
207 
212  atUint32 fileCount();
213 
218  std::vector<WiiFile*> allChildren();
219 
224  std::string fullpath();
225 protected:
226 private:
227  atUint8 m_permissions;
228  atUint8 m_attributes;
229  Type m_type;
230  std::string m_filename;
231  int m_fileLen;
232  atUint8* m_fileData;
233  WiiFile* m_parent;
234  std::vector<WiiFile*> m_children;
235 };
236 
237 } // zelda
238 #endif // WIIFILE_H
239 #endif // ATHENA_NO_SAVES
std::string fullpath()
fullpath
WiiFile * child(const std::string &name)
child
void setData(const atUint8 *data)
setData
void removeChild(const std::string &name)
removeChild
Permission
The Wii uses a bastardized unix permissions system so these flags reflect the file's individual permi...
Definition: WiiFile.hpp:44
atUint32 fileCount()
fileCount
Wii file container class.
Definition: WiiFile.hpp:36
bool isDirectory() const
isDirectory
atUint8 attributes() const
attributes
void setType(Type type)
setType
bool isFile() const
isFile
void setAttributes(const atUint8 attr)
setAttributes
void setPermissions(const atUint8 permissions)
setPermissions
void setLength(const int len)
setLength
Type type() const
type
atUint8 * data() const
data
std::vector< WiiFile * > children()
children
Type
The Type enum.
Definition: WiiFile.hpp:62
std::vector< WiiFile * > allChildren()
allChildren
int length() const
length
std::string filename() const
filename
Mask to get the Other group permissions.
Definition: WiiFile.hpp:54
void addChild(WiiFile *file)
addChild
void setParent(WiiFile *parent)
setParent
atUint8 permissions() const
permissions
WiiFile * parent()
parent
void setFilename(const std::string &filename)
setFilename