/* entry types */
#define ST_DIR 2
#define ST_FILE -3
struct Entry{
int type; /* type of the entry */
char *name; /* name */
SECTNUM sector; /* sector pointer */
char *comment; /* optional comment */
unsigned long size; /* file size, 0 for a directory */
long access; /* RWEDAPSH access rights */
int year, month, day; /* date */
int hour, min, sec; /* hour */
}
/* general purpose list used to stored directory entries */
struct List{
void *content; /* Filled with struct Entry* type */
struct List *subdir; /* If the cell content is a dir, its entries list */
/* is stored here, else filled with NULL */
struct List *next; /* Next cell */
}
adfGetDirEnt()
struct List *list, *cell;
struct Entry *entry;
/* saves the head of the list */
cell = list = adfGetDirEnt(vol,vol->curDirPtr);
/* while cell->next is NULL, the last cell */
while(cell) {
entry = (struct Entry*)cell->content;
printf("%s %ld\n", entry->name, entry->sector);
cell = cell->next;
}
/* frees the list and the content */
adfFreeDirList(list);
adfGetRDirEnt()
#define TRUE 1
int main()
{
struct List *list, *cell;
struct Entry *entry;
...
/* saves the head of the list */
cell = list = adfGetRDirEnt(vol,vol->curDirPtr,TRUE);
/* prints the tree */
printTree(cell);
/* frees the list and the content */
adfFreeDirList(list);
...
}
/* print the directories tree. recursive */
printTree(struct List* tree)
{
while(tree) {
entry = (struct Entry*)cell->content;
printf("%s %ld\n", entry->name, entry->sector);
if (tree->subdir!=NULL)
printTree(tree->subdir)
tree = tree->next;
}
}
adfChangeDir()
adfParentDir()
adfCreateDir()
adfRemoveEntry()
adfFreeDirList()
adfAccess2String()
adfRenameEntry()
printEntry()