1 /*---------------------------------------------------------------------------*
2   Project:  Horizon
3   File:     hio_Api.h
4 
5   Copyright (C)2009 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: 26495 $
14  *---------------------------------------------------------------------------*/
15 
16 #ifndef NN_HIO_CTR_HIO_API_H_
17 #define NN_HIO_CTR_HIO_API_H_
18 #ifdef  NN_SWITCH_ENABLE_HOST_IO
19 
20 /*! @file
21     @brief      HIO ライブラリの初期化、終了、バージョン取得、ファイル操作を行う API です。
22 
23 */
24 
25 #include <nn/types.h>
26 #include <nn/Result.h>
27 
28 namespace nn {
29 namespace hio {
30 namespace CTR {
31 
32 //! チャンネルオープンに必要なワークメモリのサイズ
33 const size_t WORKMEMORY_SIZE    = (80 * 1024 + 32);
34 
35 //! 最大チャンネル数
36 const size_t MAX_CHANNEL_NUM    = 12;
37 
38 /*!
39   @name     Initialize/Finalize
40 
41   @{
42 */
43 
44 /*!
45 @brief        HIO ライブラリの初期化処理を行います。ライブラリ利用前に一度呼び出す必要があります。
46 @param[in]    pDeviceMemory   ライブラリが使用するワークメモリを指定します。ワークメモリは デバイス用のメモリ である必要があり、サイズは @ref WORKMEMORY_SIZE です。
47 @return       処理の結果が返ってきます。
48 
49             デバイス用のメモリ領域は、@ref nn::os::GetDeviceMemoryAddress で取得できます。
50 
51 */
52 Result Initialize(void* pDeviceMemory);
53 
54 
55 /*!
56 @brief        HIO ライブラリの終了処理を行います。ライブラリ利用後に一度呼び出す必要があります。
57 @return       処理の結果が返ってきます。
58 */
59 Result Finalize();
60 
61 /*!
62   @}
63 */
64 
65 /*!
66 @brief        HIO ライブラリのバージョンを取得します。
67 @return       HIO ライブラリのバージョン。
68 */
69 s32 GetVersion();
70 
71 /*!
72 :overload   nounicode
73 
74 @brief              ファイルを削除します。
75 
76 @param[in]  path    ファイル名のパス。
77 
78 @return             処理の結果を返します。
79 */
80 Result DeleteFile(const char* path);
81 
82 /*!
83 :overload   unicode
84 
85 @brief              ファイルを削除します。
86 
87 @param[in]  path    ファイル名のパス。
88 
89 @return             処理の結果を返します。
90 
91 */
92 Result DeleteFile(const wchar_t* path);
93 
94 /*!
95 :overload   unicode
96 
97 @brief              ディレクトリを削除します。
98                     ディレクトリが空でない場合失敗します。
99 
100 @param[in]  path    ディレクトリのパス。
101 
102 @return             処理の結果を返します。
103 
104 */
105 Result DeleteDirectory(const wchar_t* path);
106 
107 /*!
108 :overload   nounicode
109 
110 @brief              ディレクトリを削除します。
111                     ディレクトリが空でない場合失敗します。
112 
113 @param[in]  path    ディレクトリのパス。
114 
115 @return             処理の結果を返します。
116 
117 */
118 Result DeleteDirectory(const char* path);
119 
120 /*!
121 :overload   nounicode
122 
123 @brief              ディレクトリを作成します。
124 
125 @param[in]  path    ディレクトリのパス。
126 
127 @return             処理の結果を返します。
128 
129 */
130 Result CreateDirectory(const char* path);
131 
132 /*!
133 :overload   unicode
134 
135 @brief              ディレクトリを作成します。
136 
137 @param[in]  path    ディレクトリのパス。
138 
139 @return             処理の結果を返します。
140 
141 */
142 Result CreateDirectory(const wchar_t* path);
143 
144 
145 /*!
146 :overload   nounicode
147 
148 @brief              ファイル名、ディレクトリ名を変更します。
149 
150 @param[in]  newName 新しい名前。
151 @param[in]  oldName 対象のファイル、ディレクトリのパス名。
152 
153 @return             処理の結果を返します。
154 
155 */
156 Result Rename(const char* newName, const char* oldName);
157 
158 
159 /*!
160 :overload   unicode
161 
162 @brief              ファイル名、ディレクトリ名を変更します。
163 
164 @param[in]  newName 新しい名前。
165 @param[in]  oldName 対象のファイル、ディレクトリのパス名。
166 
167 @return             処理の結果を返します。
168 
169 */
170 Result Rename(const wchar_t* newName, const wchar_t* oldName);
171 
172 /*!
173 :overload   nounicode
174 
175 @brief              カレントディレクトリを取得します。
176 
177 @param[out] pLength 実際にコピーしたサイズの格納先。
178 @param[out] buf     カレントディレクトリのパスを書き込むバッファ。
179 @param[in]  length  バッファサイズ。
180 
181 @return             処理の結果を返します。
182 
183 */
184 Result GetCurrentDirectory(s32* pLength, char* buf, s32 length);
185 
186 
187 /*!
188 :overload   unicode
189 
190 @brief              カレントディレクトリを取得します。
191 
192 @param[out] pLength 実際にコピーしたサイズの格納先。
193 @param[out] buf     カレントディレクトリのパスを書き込むバッファ。
194 @param[in]  length  バッファサイズ。
195 
196 @return             処理の結果を返します。
197 
198 */
199 Result GetCurrentDirectory(s32* pLength, wchar_t* buf, s32 length);
200 
201 /*!
202 :overload   nounicode
203 
204 @brief              カレントディレクトリを取得します。
205 
206 @param[out] buf     カレントディレクトリのパスを書き込むバッファ。
207 @param[in]  length  バッファサイズ。
208 
209 @return             実際にコピーしたサイズを返します。エラーが発生した場合は -1 を返します。
210 
211 */
212 s32 GetCurrentDirectory(char* buf, s32 length);
213 
214 /*!
215 :overload   unicode
216 
217 @brief              カレントディレクトリを取得します。
218 
219 @param[out] buf     カレントディレクトリのパスを書き込むバッファ。
220 @param[in]  length  バッファサイズ。
221 
222 @return             実際にコピーしたサイズを返します。エラーが発生した場合は -1 を返します。
223 
224 */
225 s32 GetCurrentDirectory(wchar_t* buf, s32 length);
226 
227 /*!
228 :overload   nounicode
229 
230 @brief              カレントディレクトリを設定します。
231 
232 @param[in]  path    カレントディレクトリとして設定するパスが格納されているバッファ。
233 
234 @return             処理の結果を返します。
235 
236 */
237 Result SetCurrentDirectory(const char* path);
238 
239 /*!
240 :overload   unicode
241 
242 @brief              カレントディレクトリを設定します。
243 
244 @param[in]  path    カレントディレクトリとして設定するパスが格納されているバッファ。
245 
246 @return             処理の結果を返します。
247 
248 */
249 Result SetCurrentDirectory(const wchar_t* path);
250 
251 /*!
252 :overload   nounicode_withresult
253 
254 @brief              環境変数を取得します。
255 
256 @param[out] pLength 実際にコピーしたサイズの格納先。
257 @param[out] buf     環境変数の値を格納するバッファ。
258 @param[in]  length  バッファサイズ。
259 @param[in]  name    環境変数名。
260 
261 @return             処理の結果を返します。
262 
263 */
264 Result GetEnvironmentVariable(s32* pLength, char* buf, s32 length, const char* name);
265 
266 /*!
267 :overload   nounicode_noresult
268 
269 @brief              環境変数を取得します。
270 
271 @param[out] buf     環境変数の値を格納するバッファ。
272 @param[in]  length  バッファサイズ。
273 @param[in]  name    環境変数名。
274 
275 @return             実際にコピーしたサイズを返します。エラーが発生した場合は -1 を返します。
276 
277 */
278 s32 GetEnvironmentVariable(char* buf, size_t length, const char* name);
279 
280 
281 
282 
283 /*!
284 :overload   unicode_withresult
285 
286 @brief              環境変数を取得します。
287 
288 @param[out] buf     環境変数の値を格納するバッファ。
289 @param[in]  length  バッファサイズ。
290 @param[in]  name    環境変数名。
291 
292 @return             実際にコピーしたサイズを返します。エラーが発生した場合は -1 を返します。
293 
294 */
295 Result GetEnvironmentVariable(s32* pLength, wchar_t* buf, s32 length, const wchar_t* name);
296 
297 
298 /*!
299 :overload   unicode_noresult
300 
301 @brief              環境変数を取得します。
302 
303 @param[out] buf     環境変数の値を格納するバッファ。
304 @param[in]  length  バッファサイズ。
305 @param[in]  name    環境変数名。
306 
307 @return             実際にコピーしたサイズを返します。エラーが発生した場合は -1 を返します。
308 
309 */
310 s32 GetEnvironmentVariable(wchar_t* buf, s32 length, const wchar_t* name);
311 
312 
313 
314 
315 }
316 }
317 }
318 
319 
320 #endif  // ifdef NN_SWITCH_ENABLE_HOST_IO
321 #endif  // ifndef NN_HIO_CTR_HIO_API_H_
322