1 /*---------------------------------------------------------------------------*
2   Project:  Horizon
3   File:     hio_HostDirectory.h
4 
5   Copyright (C)2009-2012 Nintendo Co., Ltd.  All rights reserved.
6 
7   These coded instructions, statements, and computer programs contain
8   proprietary information of Nintendo of America Inc. and/or Nintendo
9   Company Ltd., and are protected by Federal copyright law.  They may
10   not be disclosed to third parties or copied or duplicated in any form,
11   in whole or in part, without the prior written consent of Nintendo.
12 
13   $Rev: 46347 $
14  *---------------------------------------------------------------------------*/
15 
16 #ifndef NN_HIO_CTR_HIO_HOSTDIRECTORY_H_
17 #define NN_HIO_CTR_HIO_HOSTDIRECTORY_H_
18 #ifdef  NN_SWITCH_ENABLE_HOST_IO
19 
20 /* Please see man pages for details
21 
22 
23 
24 
25 */
26 
27 
28 #include <nn/types.h>
29 #include <nn/Result.h>
30 #include <nn/config.h>
31 #include <wchar.h>
32 
33 namespace nn {
34 namespace hio {
35 namespace CTR {
36 
37     const int MAX_PATH = 260;   //
38 
39     /* Please see man pages for details
40 
41     */
42     struct HostSystemTime
43     {
44         bit16   year;       //
45         bit16   month;      //
46         bit16   dayofweek;  //
47         bit16   day;        //
48         bit16   hour;       //
49         bit16   minute;     //
50         bit16   second;     //
51         bit16   msec;       //
52     };
53 
54     /* Please see man pages for details
55 
56 
57     */
58     enum FileAttribute
59     {
60         /* Please see man pages for details */
61         FILE_ATTRIBUTE_READ_ONLY    = (1u << 0),
62         /* Please see man pages for details */
63         FILE_ATTRIBUTE_DIRECTORY    = (1u << 4)
64     };
65 
66     class HostSystemChannel;
67 
68     //--------------------------------------------------
69     // A
70 
71     /* Please see man pages for details
72 
73 
74     */
75     struct DirectoryEntryA
76     {
77         s64             fileSize;           //
78         bit32           fileAttributes;     //
79         HostSystemTime  creationTime;       //
80         HostSystemTime  lastAccessTime;     //
81         HostSystemTime  lastWriteTime;      //
82         char            filename[MAX_PATH]; //
83     };
84 
85     /* Please see man pages for details
86 
87 
88     */
89     class HostDirectoryA
90     {
91     private:
92         s32                 m_Fd;
93         NN_PADDING4;
94         DirectoryEntryA     m_NextEntry;
95 
96     public:
97         /* Please see man pages for details
98 
99 
100         */
HostDirectoryA()101         HostDirectoryA() : m_Fd(-1)
102         {
103         }
104 
105 
106         /* Please see man pages for details
107 
108 
109         */
~HostDirectoryA()110         ~HostDirectoryA()
111         {
112             if( m_Fd > 0 )
113             {
114                 Close();
115             }
116         }
117 
118         /* Please see man pages for details
119 
120 
121 
122 
123 
124 
125         */
126         Result Open(const char* path);
127 
128         /* Please see man pages for details
129 
130 
131 
132 
133         */
134         Result Close();
135 
136 
137         /* Please see man pages for details
138 
139 
140 
141 
142 
143         */
144         Result GetNextEntry(DirectoryEntryA* pEntry);
145     };
146 
147 
148 
149     //--------------------------------------------------
150     // W
151 
152 
153     /* Please see man pages for details
154 
155     */
156     struct DirectoryEntryW
157     {
158         s64             fileSize;           //
159         bit32           fileAttributes;     //
160         HostSystemTime  creationTime;       //
161         HostSystemTime  lastAccessTime;     //
162         HostSystemTime  lastWriteTime;      //
163         wchar_t         filename[MAX_PATH]; //
164         NN_PADDING4;
165     };
166 
167     /* Please see man pages for details
168 
169     */
170     class HostDirectoryW
171     {
172     private:
173         s32                 m_Fd;
174         NN_PADDING4;
175         DirectoryEntryW     m_NextEntry;
176 
177     public:
178         /* Please see man pages for details
179 
180         */
HostDirectoryW()181         HostDirectoryW() : m_Fd(-1)
182         {
183         }
184 
185         /* Please see man pages for details
186 
187         */
~HostDirectoryW()188         ~HostDirectoryW()
189         {
190             if( m_Fd > 0 )
191             {
192                 Close();
193             }
194         }
195 
196         /* Please see man pages for details
197 
198 
199 
200 
201 
202 
203         */
204         Result Open(const wchar_t* path);
205 
206         /* Please see man pages for details
207 
208 
209 
210 
211         */
212         Result Close();
213 
214         /* Please see man pages for details
215 
216 
217 
218 
219 
220         */
221         Result GetNextEntry(DirectoryEntryW* pEntry);
222     };
223 
224 }
225 }
226 }
227 
228 
229 #endif  // ifdef NN_SWITCH_ENABLE_HOST_IO
230 #endif  // ifndef NN_HIO_CTR_HIO_HOSTDIRECTORY_H_
231