1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2<HTML>
3<HEAD>
4<META http-equiv="Content-Type" content="text/html; charset=windows-1252">
5<META http-equiv="Content-Style-Type" content="text/css">
6<TITLE>ARC API Introduction</TITLE>
7<LINK rel="stylesheet" type="text/css" href="../CSS/revolution.css">
8</HEAD>
9<BODY>
10<H1>ARC API</H1>
11
12<H2>Introduction</H2>
13<P>ARC API provides access to archive files that were made by the <CODE>darchD</CODE> utility tool.</P>
14<H2>Two Ways to Access an Archive File</H2>
15<P>There are two ways to access an archive file.</P>
16<P>* Read the entire archive file at once.</P>
17<P>You can read the entire archive file at once using <code>DVDRead(Async)</code>. To access each file in the archive, you then need to open the file with <a href="ARCOpen.html"><code>ARCOpen()</code></a>, and then get the address and length of the file by calling <a href="ARCGetStartAddrInMem.html"><code>ARCGetStartAddrInMem()</code></a> and <a href="ARCGetLength.html"><code>ARCGetLength()</code></a>. This is the easier way, but you need enough memory space to read the entire archive.</P>
18<P>* Read part of the file first, and then read each portion of the archive as needed.</P>
19<P>You can first read only part of the file, and then read each portion of the archive as needed. To do this, you need to be aware of the format of the archive file. We describe how to do this in a later section. Once you read the necessary portion of the file, you can open each file in the archive by <a href="ARCOpen.html"><code>ARCOpen()</code></a>, as in the previous method, and then can get the offset and the length of the file by calling <a href="ARCGetStartOffset.html"><code>ARCGetStartOffset()</code></a> and <a href="ARCGetLength.html"><code>ARCGetLength()</code></a>.</P>
20<H2>Format of the Archive File</H2>
21<P>An archive file consists of three parts: header, FST (file symbol table), and file.</P>
22<P>The header part is 32 bytes, and contains the FST start offset, FST size, and file start offset.</P>
23<P>The FST part has a variable size. Its format is the same as the one used in our Optical Disc Drive file system (see the Revolution Programmer's Guide for more detail).</P>
24<P>The file part contains concatenated files. Each file is 0-padded so that each starts from 32-byte aligned offset.</P>
25<P>To open an archive, you must have the header and FST in memory. To load only the header and FST in memory, you need to know either the total size of the header and FST, or the start offset of the file part. There are two ways:</P>
26<P>* Allocate statically</P>
27<P>You can tell the start offset of the file part by executing <CODE>darchD -lv arcname</CODE>. However, note that if you change the archive, the offset changes as well.</P>
28<P>* Allocate dynamically</P>
29You can dynamically tell the start offset of the file part by first reading the header (32 bytes) of the archive. The format of the header is defined in <CODE>arc.h</CODE>.
30<P><code>&nbsp;&nbsp;&nbsp; typedef struct<br> &nbsp;&nbsp;&nbsp; {<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; unsigned int magic;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int fstStart;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int fstSize;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int fileStart;<br> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; int reserve[4];<br> &nbsp;&nbsp;&nbsp; } ARCHeader;<br></code></P>
31<P><br> The member <code>fileStart</code> is the offset of the file part. You can then read the first <code>fileStart</code> bytes from the beginning of the archive file (note that the header part will be read twice).</P>
32<H2>Directory functions</H2>
33<P>As with Optical Disc Drive functions, directory access functions are provided (<code><a href="ARCChangeDir.html">ARCChangeDir()</a>, <a href="ARCGetCurrentDir.html">ARCGetCurrentDir()</a>, <a href="ARCOpenDir.html">ARCOpenDir()</a>, <a href="ARCOpenDir.html">ARCReadDir()</a></code>, etc.).</P>
34<H2>Revision History</H2>
35<P>05/15/2006 Initial version.</P>
36</BODY>
37</HTML>