1 /*---------------------------------------------------------------------------*
2   Project:  header for archiver for Revolution dvd
3   File:     arc.h
4 
5   Copyright (C) 2001-2006 Nintendo 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   $Log: arc.h,v $
14   Revision 1.3  2006/09/29 08:08:09  shirakae
15   Added ARCEntrynumIsDir
16 
17   Revision 1.2  2006/07/04 09:08:46  hiratsu
18   Added "const" to arguments.
19 
20   Revision 1.1  2006/04/19 10:50:09  hiratsu
21   Initial check-in.  Ported from Dolphin.
22 
23 
24     4     06/04/17 10:10 Hiratsu
25     Fixed comments.
26 
27     3     06/04/14 16:18 Hiratsu
28     Added include guard.
29 
30     2     02/10/07 9:39 Hashida
31     C++ support.
32 
33     1     7/02/01 11:37p Hashida
34     Initial revision.
35 
36   $NoKeywords: $
37  *---------------------------------------------------------------------------*/
38 
39 #ifndef __ARC_H__
40 #define __ARC_H__
41 
42 #include <revolution/types.h>
43 
44 #ifdef __cplusplus
45 extern "C" {
46 #endif
47 
48 typedef struct
49 {
50     unsigned int    magic;
51     int             fstStart;
52     int             fstSize;
53     int             fileStart;
54     int             reserve[4];
55 
56 } ARCHeader;
57 
58 #define DARCH_MAGIC         0x55aa382d
59 
60 typedef struct
61 {
62     void*       archiveStartAddr;
63     void*       FSTStart;
64     void*       fileStart;
65     u32         entryNum;
66     char*       FSTStringStart;
67     u32         FSTLength;
68     u32         currDir;
69 
70 } ARCHandle;
71 
72 typedef struct
73 {
74     ARCHandle*  handle;
75     u32         startOffset;
76     u32         length;
77 
78 } ARCFileInfo;
79 
80 typedef struct
81 {
82     ARCHandle*  handle;
83     u32         entryNum;
84     u32         location;
85     u32         next;
86 } ARCDir;
87 
88 typedef struct
89 {
90     ARCHandle*  handle;
91     u32         entryNum;
92     BOOL        isDir;
93     char*       name;
94 } ARCDirEntry;
95 
96 
97 BOOL  ARCInitHandle(void* arcStart, ARCHandle* handle);
98 BOOL  ARCOpen(ARCHandle* handle, const char* fileName, ARCFileInfo* af);
99 BOOL  ARCFastOpen(ARCHandle* handle, s32 entrynum, ARCFileInfo* af);
100 s32   ARCConvertPathToEntrynum(ARCHandle* handle, const char* pathPtr);
101 BOOL  ARCEntrynumIsDir( const ARCHandle * handle, s32 entrynum );
102 void* ARCGetStartAddrInMem(ARCFileInfo* af);
103 u32   ARCGetStartOffset(ARCFileInfo* af);
104 u32   ARCGetLength(ARCFileInfo* af);
105 BOOL  ARCClose(ARCFileInfo* af);
106 
107 BOOL  ARCChangeDir(ARCHandle* handle, const char* dirName);
108 BOOL  ARCGetCurrentDir(ARCHandle* handle, char* path, u32 maxlen);
109 
110 BOOL  ARCOpenDir(ARCHandle* handle, const char* dirName, ARCDir* dir);
111 BOOL  ARCReadDir(ARCDir* dir, ARCDirEntry* dirent);
112 BOOL  ARCCloseDir(ARCDir* dir);
113 
114 /*---------------------------------------------------------------------------*
115   Name:         ARCTellDir
116 
117   Description:  Returns the current location associated with the directory
118 
119   Arguments:    dir         Pre-opened ARCDir* structure
120 
121   Returns:      current location
122  *---------------------------------------------------------------------------*/
123 #define ARCTellDir(dir)             ((dir)->location)
124 
125 /*---------------------------------------------------------------------------*
126   Name:         ARCSeekDir
127 
128   Description:  Sets the position of the next ARCReadDir on the directory
129 
130   Arguments:    dir         Pre-opened ARCDir* structure
131                 loc         location to set
132 
133   Returns:      None
134  *---------------------------------------------------------------------------*/
135 #define ARCSeekDir(dir, loc)        ((dir)->location = loc)
136 
137 /*---------------------------------------------------------------------------*
138   Name:         ARCRewindDir
139 
140   Description:  Resets the position of the directory to the beginning
141 
142   Arguments:    dir         Pre-opened ARCDir* structure
143 
144   Returns:      None
145  *---------------------------------------------------------------------------*/
146 #define ARCRewindDir(dir)           ((dir)->location = (dir)->entryNum + 1)
147 
148 #define ARCGetDirEntryName(dirent)  ((dirent)->name)
149 #define ARCDirEntryIsDir(dirent)    ((dirent)->isDir)
150 
151 
152 #ifdef __cplusplus
153 }
154 #endif
155 
156 #endif  // __ARC_H__
157