1 /*---------------------------------------------------------------------------* 2 Project: Horizon 3 File: hio_HostDirectory.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: 13274 $ 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 /*! @file 21 22 @brief HostDirectory クラスを定義します。 23 24 :include nn/hio.h 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; //!< 扱うことのできる最大パス長を示します。この値には末尾の NULL も含まれます。 38 39 /*! 40 @brief タイムスタンプを表す構造体です。 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 /*! 55 @brief ファイル属性を表す列挙体です。 56 57 */ 58 enum FileAttribute 59 { 60 /*! @brief 読み込み専用であることを示します。 */ 61 FILE_ATTRIBUTE_READ_ONLY = (1u << 0), 62 /*! @brief ディレクトリであることを示します。 */ 63 FILE_ATTRIBUTE_DIRECTORY = (1u << 4) 64 }; 65 66 class HostSystemChannel; 67 68 //-------------------------------------------------- 69 // A 70 71 /*! 72 @brief ディレクトリエントリを表す構造体です。 73 74 */ 75 struct DirectoryEntryA 76 { 77 s64 fileSize; //!< ファイルサイズをバイト単位で表します。 78 bit32 fileAttributes; //!< 属性を @ref FileAttribute 型で表します。 79 HostSystemTime creationTime; //!< 作成された日時を @ref HostSystemTime 型で表します。 80 HostSystemTime lastAccessTime; //!< 最後にアクセスされた日時を @ref HostSystemTime 型で表します。 81 HostSystemTime lastWriteTime; //!< 最後に書き込まれた日時を @ref HostSystemTime 型で表します。 82 char filename[MAX_PATH]; //!< ファイル名を示します。 83 }; 84 85 /*! 86 @brief ホストファイルシステムのディレクトリを表すクラスです。ディレクトリに属するエントリ情報を取得することができます。 87 88 */ 89 class HostDirectoryA 90 { 91 private: 92 s32 m_Fd; 93 NN_PADDING4; 94 DirectoryEntryA m_NextEntry; 95 96 public: 97 /*! 98 @brief コンストラクタです。別途 @ref Open() を呼び出して、操作対象のディレクトリをオープンする必要があります。 99 100 */ HostDirectoryA()101 HostDirectoryA() : m_Fd(-1) 102 { 103 } 104 105 106 /*! 107 @brief デストラクタです。ディレクトリがオープンされている場合はクローズします。 108 109 */ ~HostDirectoryA()110 ~HostDirectoryA() 111 { 112 if( m_Fd > 0 ) 113 { 114 Close(); 115 } 116 } 117 118 /*! 119 @brief ディレクトリをオープンします。 120 @ref GetNextEntry() によって、オープン済みのディレクトリに属するディレクトリエントリを取得することができるようになります。 121 122 @param[in] path オープンするディレクトリのパスを指定します。 123 @return 処理の結果を返します。 124 125 */ 126 Result Open(const char* path); 127 128 /*! 129 @brief ディレクトリをクローズします。 130 131 @return 処理の結果を返します。 132 133 */ 134 Result Close(); 135 136 137 /*! 138 @brief ディレクトリエントリを取得します。 139 140 @param[out] pEntry 取得したエントリの格納先を指定します。 141 @return 処理の結果を返します。 142 143 */ 144 Result GetNextEntry(DirectoryEntryA* pEntry); 145 }; 146 147 148 149 //-------------------------------------------------- 150 // W 151 152 153 /*! 154 @brief @ref DirectoryEntryA の Unicode 対応版です。 155 */ 156 struct DirectoryEntryW 157 { 158 s64 fileSize; //!< ファイルサイズをバイト単位で表します。 159 bit32 fileAttributes; //!< 属性を @ref FileAttribute 型で表します。 160 HostSystemTime creationTime; //!< 作成された日時を @ref HostSystemTime 型で表します。 161 HostSystemTime lastAccessTime; //!< 最後にアクセスされた日時を @ref HostSystemTime 型で表します。 162 HostSystemTime lastWriteTime; //!< 最後に書き込まれた日時を @ref HostSystemTime 型で表します。 163 wchar_t filename[MAX_PATH]; //!< ファイル名を示します。 164 NN_PADDING4; 165 }; 166 167 /*! 168 @brief @ref HostDirectoryA の Unicode 対応版です。 169 */ 170 class HostDirectoryW 171 { 172 private: 173 s32 m_Fd; 174 NN_PADDING4; 175 DirectoryEntryW m_NextEntry; 176 177 public: 178 /*! 179 @brief コンストラクタです。別途 @ref Open() を呼び出して、操作対象のディレクトリをオープンする必要があります。 180 */ HostDirectoryW()181 HostDirectoryW() : m_Fd(-1) 182 { 183 } 184 185 /*! 186 @brief デストラクタです。ディレクトリがオープンされている場合はクローズします。 187 */ ~HostDirectoryW()188 ~HostDirectoryW() 189 { 190 if( m_Fd > 0 ) 191 { 192 Close(); 193 } 194 } 195 196 /*! 197 @brief ディレクトリをオープンします。 198 @ref GetNextEntry() によって、オープン済みのディレクトリに属するディレクトリエントリを取得することができるようになります。 199 200 @param[in] path オープンするディレクトリのパスを指定します。 201 @return 処理の結果を返します。 202 203 */ 204 Result Open(const wchar_t* path); 205 206 /*! 207 @brief ディレクトリをクローズします。 208 209 @return 処理の結果を返します。 210 211 */ 212 Result Close(); 213 214 /*! 215 @brief ディレクトリエントリを取得します。 216 217 @param[out] pEntry 取得したエントリの格納先を指定します。 218 @return 処理の結果を返します。 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