/*---------------------------------------------------------------------------* Project: NintendoWare File: lyt_Arc.h Copyright (C)2009-2010 Nintendo Co., Ltd./HAL Laboratory, Inc. All rights reserved. These coded instructions, statements, and computer programs contain proprietary information of Nintendo of America Inc. and/or Nintendo Company Ltd., and are protected by Federal copyright law. They may not be disclosed to third parties or copied or duplicated in any form, in whole or in part, without the prior written consent of Nintendo. $Revision: 14502 $ *---------------------------------------------------------------------------*/ #ifndef NW_LYT_ARC_H_ #define NW_LYT_ARC_H_ #if defined(_MSC_VER) && _MSC_VER >= 1500 #pragma once #endif #include namespace nw { namespace lyt { typedef struct { u32 signature; //!< ファイルシグネチャ u16 byteOrder; //!< バイトオーダーマーク u16 headerSize; //!< ヘッダサイズ u32 version; //!< ファイルバージョン u32 fileSize; //!< ファイルサイズ s32 fstStart; //!< エントリテーブル部の開始位置 s32 fstSize; //!< エントリテーブル部のサイズ s32 fileStart; //!< ファイルデータ部の開始位置 } ARCHeader; const u32 DARCH_SIGNATURE = 0x63726164; // 'darc' const u16 DARCH_BYTE_ORDER_MARK = 0xFEFF; const u32 DARCH_VERSION = 0x01000000; typedef struct { void* archiveStartAddr; void* FSTStart; void* fileStart; u32 entryNum; wchar_t* FSTStringStart; u32 FSTLength; u32 currDir; } ARCHandle; typedef struct { ARCHandle* handle; u32 startOffset; u32 length; } ARCFileInfo; typedef struct { ARCHandle* handle; u32 entryNum; u32 location; u32 next; } ARCDir; typedef struct { ARCHandle* handle; u32 entryNum; bool isDir; wchar_t* name; } ARCDirEntry; bool ARCInitHandle(void* arcStart, ARCHandle* handle); bool ARCOpen(ARCHandle* handle, const wchar_t* fileName, ARCFileInfo* af); bool ARCFastOpen(ARCHandle* handle, s32 entrynum, ARCFileInfo* af); s32 ARCConvertPathToEntrynum(ARCHandle* handle, const wchar_t* pathPtr); bool ARCEntrynumIsDir( const ARCHandle * handle, s32 entrynum ); void* ARCGetStartAddrInMem(ARCFileInfo* af); u32 ARCGetStartOffset(ARCFileInfo* af); u32 ARCGetLength(ARCFileInfo* af); bool ARCClose(ARCFileInfo* af); bool ARCChangeDir(ARCHandle* handle, const wchar_t* dirName); bool ARCGetCurrentDir(ARCHandle* handle, wchar_t* path, u32 maxlen); bool ARCOpenDir(ARCHandle* handle, const wchar_t* dirName, ARCDir* dir); bool ARCReadDir(ARCDir* dir, ARCDirEntry* dirent); bool ARCCloseDir(ARCDir* dir); /*---------------------------------------------------------------------------* Description: Returns the current location associated with the directory Arguments: dir Pre-opened ARCDir* structure Returns: current location *---------------------------------------------------------------------------*/ #define ARCTellDir(dir) ((dir)->location) /*---------------------------------------------------------------------------* Description: Sets the position of the next ARCReadDir on the directory Arguments: dir Pre-opened ARCDir* structure loc location to set Returns: None *---------------------------------------------------------------------------*/ #define ARCSeekDir(dir, loc) ((dir)->location = loc) /*---------------------------------------------------------------------------* Description: Resets the position of the directory to the beginning Arguments: dir Pre-opened ARCDir* structure Returns: None *---------------------------------------------------------------------------*/ #define ARCRewindDir(dir) ((dir)->location = (dir)->entryNum + 1) #define ARCGetDirEntryName(dirent) ((dirent)->name) #define ARCDirEntryIsDir(dirent) ((dirent)->isDir) } // namespace lyt } // namespace nw #endif // NW_LYT_ARC_H_