From 59185346dd02788ad2bc793f6b9f6687fd26d31d Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Sun, 8 Jul 2001 10:58:10 +0000 Subject: [PATCH] More tweaks; GRP completely implemented. Everything builds clean. --- Makefile | 5 +++++ archivers/dir.c | 10 +++++----- archivers/zip.c | 9 +++++---- physfs.c | 5 +++++ physfs_internal.h | 1 + 5 files changed, 21 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 14a9462b..2a6ce30b 100644 --- a/Makefile +++ b/Makefile @@ -145,6 +145,11 @@ MAINSRCS += archivers/zip.c CFLAGS += -DPHYSFS_SUPPORTS_ZIP endif +ifeq ($(strip $(use_archive_grp)),true) +MAINSRCS += archivers/grp.c +CFLAGS += -DPHYSFS_SUPPORTS_GRP +endif + # Rule for getting list of objects from source MAINOBJS1 := $(MAINSRCS:.c=.o) MAINOBJS2 := $(MAINOBJS1:.cpp=.o) diff --git a/archivers/dir.c b/archivers/dir.c index fd109cc5..59393b2f 100644 --- a/archivers/dir.c +++ b/archivers/dir.c @@ -14,6 +14,7 @@ #include #include #include +#include "physfs.h" #define __PHYSICSFS_INTERNAL__ #include "physfs_internal.h" @@ -30,8 +31,7 @@ static int DIR_read(FileHandle *handle, void *buffer, errno = 0; retval = fread(buffer, objSize, objCount, h); - if ( (retval < objCount) && (ferror(h)) ) - __PHYSFS_setError(strerror(errno)); + BAIL_IF_MACRO((retval < objCount) && (ferror(h)),strerror(errno),retval); return(retval); } /* DIR_read */ @@ -294,7 +294,7 @@ static const FileFunctions __PHYSFS_FileFunctions_DIRW = DIR_eof, /* eof() method */ DIR_tell, /* tell() method */ DIR_seek, /* seek() method */ - DIR_fileClose, /* fileClose() method */ + DIR_fileClose /* fileClose() method */ }; @@ -311,13 +311,13 @@ const DirFunctions __PHYSFS_DirFunctions_DIR = DIR_openAppend, /* openAppend() method */ DIR_remove, /* remove() method */ DIR_mkdir, /* mkdir() method */ - DIR_dirClose, /* dirClose() method */ + DIR_dirClose /* dirClose() method */ }; /* This doesn't get listed, since it's technically not an archive... */ #if 0 -const __PHYSFS_ArchiveInfo __PHYSFS_ArchiveInfo_DIR = +const PHYSFS_ArchiveInfo __PHYSFS_ArchiveInfo_DIR = { "DIR", "non-archive directory I/O" diff --git a/archivers/zip.c b/archivers/zip.c index 37cf6ca3..0e11af06 100644 --- a/archivers/zip.c +++ b/archivers/zip.c @@ -8,6 +8,7 @@ #include #include +#include "physfs.h" #define __PHYSICSFS_INTERNAL__ #include "physfs_internal.h" @@ -17,7 +18,7 @@ #endif extern const DirFunctions __PHYSFS_DirFunctions_ZIP; -extern const FileFunctions __PHYSFS_FileHandle_ZIP; +static const FileFunctions __PHYSFS_FileFunctions_ZIP; static int ZIP_read(FileHandle *handle, void *buffer, @@ -93,7 +94,7 @@ static const FileFunctions __PHYSFS_FileFunctions_ZIP = ZIP_eof, /* eof() method */ ZIP_tell, /* tell() method */ ZIP_seek, /* seek() method */ - ZIP_fileClose, /* fileClose() method */ + ZIP_fileClose /* fileClose() method */ }; @@ -110,10 +111,10 @@ const DirFunctions __PHYSFS_DirFunctions_ZIP = NULL, /* openAppend() method */ NULL, /* remove() method */ NULL, /* mkdir() method */ - ZIP_dirClose, /* dirClose() method */ + ZIP_dirClose /* dirClose() method */ }; -const __PHYSFS_ArchiveInfo __PHYSFS_ArchiveInfo_ZIP = +const PHYSFS_ArchiveInfo __PHYSFS_ArchiveInfo_ZIP = { "ZIP", "PkZip/WinZip/Info-Zip compatible" diff --git a/physfs.c b/physfs.c index dab0705a..d6c6e3ab 100644 --- a/physfs.c +++ b/physfs.c @@ -46,6 +46,11 @@ extern const PHYSFS_ArchiveInfo __PHYSFS_ArchiveInfo_ZIP; extern const DirFunctions __PHYSFS_DirFunctions_ZIP; #endif +#if (defined PHYSFS_SUPPORTS_GRP) +extern const PHYSFS_ArchiveInfo __PHYSFS_ArchiveInfo_GRP; +extern const DirFunctions __PHYSFS_DirFunctions_GRP; +#endif + extern const DirFunctions __PHYSFS_DirFunctions_DIR; static const PHYSFS_ArchiveInfo *supported_types[] = diff --git a/physfs_internal.h b/physfs_internal.h index 7a48e741..3f7d3752 100644 --- a/physfs_internal.h +++ b/physfs_internal.h @@ -240,6 +240,7 @@ typedef struct __PHYSFS_DIRFUNCTIONS__ #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" +#define ERR_ARC_IS_READ_ONLY "Archive is read-only" /* * Call this to set the message returned by PHYSFS_getLastError().