From ee508bb2e0e20a02bff077f60eac70e7596125fa Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Sun, 8 Jul 2001 05:27:05 +0000 Subject: [PATCH] Archive implementation (Build Groupfiles), other tweaks. --- Makefile | 2 +- archivers/dir.c | 13 +++++++------ archivers/zip.c | 14 +++++++------- physfs.c | 8 ++++++++ physfs_internal.h | 2 +- 5 files changed, 24 insertions(+), 15 deletions(-) diff --git a/Makefile b/Makefile index 2c7d29a8..14a9462b 100644 --- a/Makefile +++ b/Makefile @@ -38,6 +38,7 @@ debugging := true # Note that various archives may need external libraries. #-----------------------------------------------------------------------------# use_archive_zip := false +use_archive_grp := true #-----------------------------------------------------------------------------# # Set to "true" if you'd like to build a DLL. Set to "false" otherwise. @@ -45,7 +46,6 @@ use_archive_zip := false #build_dll := false build_dll := true - #-----------------------------------------------------------------------------# # Set one of the below. Currently, none of these are used. #-----------------------------------------------------------------------------# diff --git a/archivers/dir.c b/archivers/dir.c index 126b397d..fd109cc5 100644 --- a/archivers/dir.c +++ b/archivers/dir.c @@ -19,8 +19,8 @@ #include "physfs_internal.h" extern const DirFunctions __PHYSFS_DirFunctions_DIR; -static const FileFunctions __PHYSFS_FileHandle_DIR; -static const FileFunctions __PHYSFS_FileHandle_DIRW; +static const FileFunctions __PHYSFS_FileFunctions_DIR; +static const FileFunctions __PHYSFS_FileFunctions_DIRW; static int DIR_read(FileHandle *handle, void *buffer, unsigned int objSize, unsigned int objCount) @@ -112,7 +112,8 @@ static DirHandle *DIR_openArchive(const char *name, int forWriting) int namelen = strlen(name); int seplen = strlen(dirsep); - BAIL_IF_MACRO(!DIR_isArchive(name, 0), ERR_UNSUPPORTED_ARCHIVE, NULL); + BAIL_IF_MACRO(!DIR_isArchive(name, forWriting), + ERR_UNSUPPORTED_ARCHIVE, NULL); retval = malloc(sizeof (DirHandle)); BAIL_IF_MACRO(retval == NULL, ERR_OUT_OF_MEMORY, NULL); @@ -210,7 +211,7 @@ static FileHandle *doOpen(DirHandle *h, const char *name, const char *mode) retval->opaque = (void *) rc; retval->dirHandle = h; - retval->funcs = &__PHYSFS_FileHandle_DIR; + retval->funcs = &__PHYSFS_FileFunctions_DIR; return(retval); } /* doOpen */ @@ -275,7 +276,7 @@ static void DIR_dirClose(DirHandle *h) -static const FileFunctions __PHYSFS_FileHandle_DIR = +static const FileFunctions __PHYSFS_FileFunctions_DIR = { DIR_read, /* read() method */ NULL, /* write() method */ @@ -286,7 +287,7 @@ static const FileFunctions __PHYSFS_FileHandle_DIR = }; -static const FileFunctions __PHYSFS_FileHandle_DIRW = +static const FileFunctions __PHYSFS_FileFunctions_DIRW = { NULL, /* read() method */ DIR_write, /* write() method */ diff --git a/archivers/zip.c b/archivers/zip.c index fae24015..37cf6ca3 100644 --- a/archivers/zip.c +++ b/archivers/zip.c @@ -56,37 +56,37 @@ static DirHandle *ZIP_openArchive(const char *name, int forWriting) } /* ZIP_openArchive */ -static LinkedStringList *ZIP_enumerateFiles(DirHandle *r, const char *dirname) +static LinkedStringList *ZIP_enumerateFiles(DirHandle *h, const char *dirname) { } /* ZIP_enumerateFiles */ -static int ZIP_exists(DirHandle *r, const char *name) +static int ZIP_exists(DirHandle *h, const char *name) { } /* ZIP_exists */ -static int ZIP_isDirectory(DirHandle *r, const char *name) +static int ZIP_isDirectory(DirHandle *h, const char *name) { } /* ZIP_isDirectory */ -static int ZIP_isSymLink(DirHandle *r, const char *name) +static int ZIP_isSymLink(DirHandle *h, const char *name) { } /* ZIP_isSymLink */ -static FileHandle *ZIP_openRead(DirHandle *r, const char *filename) +static FileHandle *ZIP_openRead(DirHandle *h, const char *filename) { } /* ZIP_openRead */ -static void ZIP_dirClose(DirHandle *r) +static void ZIP_dirClose(DirHandle *h) { } /* ZIP_dirClose */ -static const FileFunctions __PHYSFS_FileHandle_ZIP = +static const FileFunctions __PHYSFS_FileFunctions_ZIP = { ZIP_read, /* read() method */ NULL, /* write() method */ diff --git a/physfs.c b/physfs.c index 5d91f803..dab0705a 100644 --- a/physfs.c +++ b/physfs.c @@ -54,6 +54,10 @@ static const PHYSFS_ArchiveInfo *supported_types[] = &__PHYSFS_ArchiveInfo_ZIP, #endif +#if (defined PHYSFS_SUPPORTS_GRP) + &__PHYSFS_ArchiveInfo_GRP, +#endif + NULL }; @@ -63,6 +67,10 @@ static const DirFunctions *dirFunctions[] = &__PHYSFS_DirFunctions_ZIP, #endif +#if (defined PHYSFS_SUPPORTS_GRP) + &__PHYSFS_DirFunctions_GRP, +#endif + &__PHYSFS_DirFunctions_DIR, NULL }; diff --git a/physfs_internal.h b/physfs_internal.h index 3a14bdc8..7a48e741 100644 --- a/physfs_internal.h +++ b/physfs_internal.h @@ -239,7 +239,7 @@ typedef struct __PHYSFS_DIRFUNCTIONS__ #define ERR_SYMLINK_DISALLOWED "Symbolic links are disabled" #define ERR_NO_WRITE_DIR "Write directory is not set" #define ERR_NO_SUCH_FILE "No such file" - +#define ERR_PAST_EOF "Past end of file" /* * Call this to set the message returned by PHYSFS_getLastError().