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