summaryrefslogtreecommitdiff
path: root/mpq-fs.c
diff options
context:
space:
mode:
authorpixel <pixel>2007-07-11 14:23:29 +0000
committerpixel <pixel>2007-07-11 14:23:29 +0000
commit26fcbbdd26a389b6979a966ae8dd49a40a6a1d05 (patch)
treebbf63c4080bcba14aa7d02176dc23b920a70514c /mpq-fs.c
parent2b81447acc91685dbfb6419282a0f53b6ac3eaa0 (diff)
Adding comments.
Diffstat (limited to 'mpq-fs.c')
-rw-r--r--mpq-fs.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/mpq-fs.c b/mpq-fs.c
index b4c8fd7..ae9ed02 100644
--- a/mpq-fs.c
+++ b/mpq-fs.c
@@ -28,6 +28,9 @@ static char * strtoupper(char * _str) {
return _str;
}
+/*
+ * The 'new' keyword is abusive: the function returns an existing entry if it matches, allowing overrites.
+ */
static directory_list * new_directory_list(directory_list * parent, struct mpq_archive_t * mpq_a, const char * name) {
directory_list * r;
@@ -49,6 +52,9 @@ static directory_list * new_directory_list(directory_list * parent, struct mpq_a
return r;
}
+/*
+ * Recursively adds a new entry into our directory structure.
+ */
static directory_list * add_file_r(directory_list * parent, struct mpq_archive_t * mpq_a, char * fname, int entry) {
char * bs;
directory_list * r;
@@ -81,6 +87,9 @@ static directory_list * add_file(struct mpq_archive_t * mpq_a, char * fname) {
return add_file_r(root, mpq_a, fname, entry);
}
+/*
+ * Adds an opened archive file into the system, and try to automagically import the list file.
+ */
void mpqlib_fs_add_archive(struct mpq_archive_t * mpq_a) {
struct mpq_file_t * listfile;
char * buffer;
@@ -105,6 +114,9 @@ void mpqlib_fs_add_archive(struct mpq_archive_t * mpq_a) {
mpqlib_close(listfile);
}
+/*
+ * Generalistic function to add an archive to the directory structure using a custom listfile.
+ */
void mpqlib_fs_attach_listfile(struct mpq_archive_t * mpq_a, const char * listfile) {
char fname[MAX_FNAME];
const char * p;
@@ -112,6 +124,7 @@ void mpqlib_fs_attach_listfile(struct mpq_archive_t * mpq_a, const char * listfi
for (p = listfile, fnp = fname; *p; p++) {
switch (*p) {
+ /* Each entry in the listfile may be separated by CR, LF, and/or ';'. */
case '\r':
case '\n':
case ';':
@@ -127,6 +140,9 @@ void mpqlib_fs_attach_listfile(struct mpq_archive_t * mpq_a, const char * listfi
}
}
+/*
+ * Recursively find a file.
+ */
static directory_list * find_file_r(directory_list * parent, char * fname) {
char * bs;
directory_list * r;