[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[paragui-cvs] CVS: paragui/src/physfs/archivers Makefile.am,1.2,1.2.2.1
From: |
Teunis Peters <address@hidden> |
Subject: |
[paragui-cvs] CVS: paragui/src/physfs/archivers Makefile.am,1.2,1.2.2.1 dir.c,1.2,1.2.2.1 grp.c,1.2,1.2.2.1 unzip.c,1.2,1.2.2.1 zip.c,1.2,1.2.2.1 |
Date: |
Sat, 31 Aug 2002 00:01:27 -0400 |
Update of /cvsroot/paragui/paragui/src/physfs/archivers
In directory subversions:/tmp/cvs-serv4328/src/physfs/archivers
Modified Files:
Tag: devel-opengl
Makefile.am dir.c grp.c unzip.c zip.c
Log Message:
massive changes - updates from main trunk and various bugfixes
Index: Makefile.am
===================================================================
RCS file: /cvsroot/paragui/paragui/src/physfs/archivers/Makefile.am,v
retrieving revision 1.2
retrieving revision 1.2.2.1
diff -C2 -r1.2 -r1.2.2.1
*** Makefile.am 27 Apr 2002 16:06:26 -0000 1.2
--- Makefile.am 31 Aug 2002 04:01:23 -0000 1.2.2.1
***************
*** 1,12 ****
! noinst_LTLIBRARIES=libarchivers.la
! libarchivers_la_SOURCES = \
! dir.c \
! unzip.c \
! zip.c
! INCLUDES=-I$(top_srcdir)/src/physfs -DPHYSFS_SUPPORTS_ZIP
- EXTRA_DIST = \
- grp.c \
- unzip.h
--- 1,13 ----
! noinst_LTLIBRARIES = libarchivers.la
! if BUILD_ZLIB
! INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/zlib114
! else
! INCLUDES = -I$(top_srcdir)
! endif
! libarchivers_la_SOURCES = \
! dir.c \
! grp.c \
! zip.c
Index: dir.c
===================================================================
RCS file: /cvsroot/paragui/paragui/src/physfs/archivers/dir.c,v
retrieving revision 1.2
retrieving revision 1.2.2.1
diff -C2 -r1.2 -r1.2.2.1
*** dir.c 27 Apr 2002 16:06:26 -0000 1.2
--- dir.c 31 Aug 2002 04:01:23 -0000 1.2.2.1
***************
*** 7,10 ****
--- 7,14 ----
*/
+ #if HAVE_CONFIG_H
+ # include <config.h>
+ #endif
+
#include <stdio.h>
#include <stdlib.h>
***************
*** 35,38 ****
--- 39,43 ----
static int DIR_isSymLink(DirHandle *h, const char *name);
static FileHandle *DIR_openRead(DirHandle *h, const char *filename);
+ static PHYSFS_sint64 DIR_getLastModTime(DirHandle *h, const char *name);
static FileHandle *DIR_openWrite(DirHandle *h, const char *filename);
static FileHandle *DIR_openAppend(DirHandle *h, const char *filename);
***************
*** 42,54 ****
static const FileFunctions __PHYSFS_FileFunctions_DIR =
{
! DIR_read, /* read() method */
! NULL, /* write() method */
! DIR_eof, /* eof() method */
! DIR_tell, /* tell() method */
! DIR_seek, /* seek() method */
DIR_fileLength, /* fileLength() method */
! DIR_fileClose /* fileClose() method */
};
--- 47,68 ----
+ const PHYSFS_ArchiveInfo __PHYSFS_ArchiveInfo_DIR =
+ {
+ "",
+ DIR_ARCHIVE_DESCRIPTION,
+ "Ryan C. Gordon <address@hidden>",
+ "http://icculus.org/physfs/",
+ };
+
+
static const FileFunctions __PHYSFS_FileFunctions_DIR =
{
! DIR_read, /* read() method */
! NULL, /* write() method */
! DIR_eof, /* eof() method */
! DIR_tell, /* tell() method */
! DIR_seek, /* seek() method */
DIR_fileLength, /* fileLength() method */
! DIR_fileClose /* fileClose() method */
};
***************
*** 68,71 ****
--- 82,86 ----
const DirFunctions __PHYSFS_DirFunctions_DIR =
{
+ &__PHYSFS_ArchiveInfo_DIR,
DIR_isArchive, /* isArchive() method */
DIR_openArchive, /* openArchive() method */
***************
*** 74,77 ****
--- 89,93 ----
DIR_isDirectory, /* isDirectory() method */
DIR_isSymLink, /* isSymLink() method */
+ DIR_getLastModTime, /* getLastModTime() method */
DIR_openRead, /* openRead() method */
DIR_openWrite, /* openWrite() method */
***************
*** 83,98 ****
- /* This doesn't get listed, since it's technically not an archive... */
- #if 0
- const PHYSFS_ArchiveInfo __PHYSFS_ArchiveInfo_DIR =
- {
- "DIR",
- "non-archive directory I/O",
- "Ryan C. Gordon <address@hidden>",
- "http://www.icculus.org/physfs/",
- };
- #endif
-
-
static PHYSFS_sint64 DIR_read(FileHandle *handle, void *buffer,
PHYSFS_uint32 objSize, PHYSFS_uint32 objCount)
--- 99,102 ----
***************
*** 231,239 ****
int retval;
! BAIL_IF_MACRO(f == NULL, NULL, 0); /* !!! might be a problem. */
retval = __PHYSFS_platformIsSymLink(f);
free(f);
return(retval);
} /* DIR_isSymLink */
--- 235,255 ----
int retval;
! BAIL_IF_MACRO(f == NULL, NULL, 0);
retval = __PHYSFS_platformIsSymLink(f);
free(f);
return(retval);
} /* DIR_isSymLink */
+
+
+ static PHYSFS_sint64 DIR_getLastModTime(DirHandle *h, const char *name)
+ {
+ char *d = __PHYSFS_platformCvtToDependent((char *)(h->opaque), name,
NULL);
+ PHYSFS_sint64 retval;
+
+ BAIL_IF_MACRO(d == NULL, NULL, 0);
+ retval = __PHYSFS_platformGetLastModTime(d);
+ free(d);
+ return(retval);
+ } /* DIR_getLastModTime */
Index: grp.c
===================================================================
RCS file: /cvsroot/paragui/paragui/src/physfs/archivers/grp.c,v
retrieving revision 1.2
retrieving revision 1.2.2.1
diff -C2 -r1.2 -r1.2.2.1
*** grp.c 27 Apr 2002 16:06:26 -0000 1.2
--- grp.c 31 Aug 2002 04:01:23 -0000 1.2.2.1
***************
*** 20,27 ****
* (That info is from http://www.advsys.net/ken/build.htm ...)
*
- * As it was never a concern in the DOS-based Duke Nukem days, I treat these
- * archives as CASE-INSENSITIVE. Opening "myfile.txt" and "MYFILE.TXT" both
- * work, and get the same file.
- *
* Please see the file LICENSE in the source's root directory.
*
--- 20,23 ----
***************
*** 29,32 ****
--- 25,34 ----
*/
+ #if HAVE_CONFIG_H
+ # include <config.h>
+ #endif
+
+ #if (defined PHYSFS_SUPPORTS_GRP)
+
#include <stdio.h>
#include <stdlib.h>
***************
*** 40,52 ****
#include "physfs_internal.h"
! #if (!defined PHYSFS_SUPPORTS_GRP)
! #error PHYSFS_SUPPORTS_GRP must be defined.
! #endif
typedef struct
{
- void *handle;
char *filename;
! PHYSFS_uint32 totalEntries;
} GRPinfo;
--- 42,65 ----
#include "physfs_internal.h"
! /*
! * When sorting the grp entries in an archive, we use a modified QuickSort.
! * When there are less then GRP_QUICKSORT_THRESHOLD entries left to sort,
! * we switch over to an InsertionSort for the remainder. Tweak to taste.
! */
! #define GRP_QUICKSORT_THRESHOLD 4
!
! typedef struct
! {
! char name[13];
! PHYSFS_uint64 startPos;
! PHYSFS_uint64 size;
! } GRPentry;
typedef struct
{
char *filename;
! PHYSFS_sint64 last_mod_time;
! PHYSFS_uint32 entryCount;
! GRPentry *entries;
} GRPinfo;
***************
*** 54,59 ****
{
void *handle;
! PHYSFS_uint64 startPos;
! PHYSFS_uint64 size;
} GRPfileinfo;
--- 67,72 ----
{
void *handle;
! GRPentry *entry;
! PHYSFS_sint64 curPos;
} GRPfileinfo;
***************
*** 75,80 ****
--- 88,103 ----
static int GRP_isDirectory(DirHandle *h, const char *name);
static int GRP_isSymLink(DirHandle *h, const char *name);
+ static PHYSFS_sint64 GRP_getLastModTime(DirHandle *h, const char *name);
static FileHandle *GRP_openRead(DirHandle *h, const char *name);
+ const PHYSFS_ArchiveInfo __PHYSFS_ArchiveInfo_GRP =
+ {
+ "GRP",
+ GRP_ARCHIVE_DESCRIPTION,
+ "Ryan C. Gordon <address@hidden>",
+ "http://icculus.org/physfs/",
+ };
+
+
static const FileFunctions __PHYSFS_FileFunctions_GRP =
{
***************
*** 91,94 ****
--- 114,118 ----
const DirFunctions __PHYSFS_DirFunctions_GRP =
{
+ &__PHYSFS_ArchiveInfo_GRP,
GRP_isArchive, /* isArchive() method */
GRP_openArchive, /* openArchive() method */
***************
*** 97,100 ****
--- 121,125 ----
GRP_isDirectory, /* isDirectory() method */
GRP_isSymLink, /* isSymLink() method */
+ GRP_getLastModTime, /* getLastModTime() method */
GRP_openRead, /* openRead() method */
NULL, /* openWrite() method */
***************
*** 105,123 ****
};
- const PHYSFS_ArchiveInfo __PHYSFS_ArchiveInfo_GRP =
- {
- "GRP",
- "Build engine Groupfile format",
- "Ryan C. Gordon <address@hidden>",
- "http://www.icculus.org/physfs/",
- };
-
static void GRP_dirClose(DirHandle *h)
{
! __PHYSFS_platformClose( ((GRPinfo *) h->opaque)->handle );
! free(((GRPinfo *) h->opaque)->filename);
! free(h->opaque);
free(h);
} /* GRP_dirClose */
--- 130,141 ----
};
static void GRP_dirClose(DirHandle *h)
{
! GRPinfo *info = ((GRPinfo *) h->opaque);
! free(info->filename);
! free(info->entries);
! free(info);
free(h);
} /* GRP_dirClose */
***************
*** 128,140 ****
{
GRPfileinfo *finfo = (GRPfileinfo *) (handle->opaque);
! void *fh = finfo->handle;
! PHYSFS_sint64 curPos = __PHYSFS_platformTell(fh);
! PHYSFS_uint64 bytesLeft = (finfo->startPos + finfo->size) - curPos;
PHYSFS_uint64 objsLeft = (bytesLeft / objSize);
if (objsLeft < objCount)
objCount = (PHYSFS_uint32) objsLeft;
! return(__PHYSFS_platformRead(fh, buffer, objSize, objCount));
} /* GRP_read */
--- 146,162 ----
{
GRPfileinfo *finfo = (GRPfileinfo *) (handle->opaque);
! GRPentry *entry = finfo->entry;
! PHYSFS_uint64 bytesLeft = entry->size - finfo->curPos;
PHYSFS_uint64 objsLeft = (bytesLeft / objSize);
+ PHYSFS_sint64 rc;
if (objsLeft < objCount)
objCount = (PHYSFS_uint32) objsLeft;
! rc = __PHYSFS_platformRead(finfo->handle, buffer, objSize, objCount);
! if (rc > 0)
! finfo->curPos += (rc * objSize);
!
! return(rc);
} /* GRP_read */
***************
*** 143,150 ****
{
GRPfileinfo *finfo = (GRPfileinfo *) (handle->opaque);
! void *fh = finfo->handle;
! PHYSFS_sint64 pos = __PHYSFS_platformTell(fh);
! BAIL_IF_MACRO(pos < 0, NULL, 1); /* (*shrug*) */
! return(pos >= (PHYSFS_sint64) (finfo->startPos + finfo->size));
} /* GRP_eof */
--- 165,170 ----
{
GRPfileinfo *finfo = (GRPfileinfo *) (handle->opaque);
! GRPentry *entry = finfo->entry;
! return(finfo->curPos >= (PHYSFS_sint64) entry->size);
} /* GRP_eof */
***************
*** 152,157 ****
static PHYSFS_sint64 GRP_tell(FileHandle *handle)
{
! GRPfileinfo *finfo = (GRPfileinfo *) (handle->opaque);
! return(__PHYSFS_platformTell(finfo->handle) - finfo->startPos);
} /* GRP_tell */
--- 172,176 ----
static PHYSFS_sint64 GRP_tell(FileHandle *handle)
{
! return(((GRPfileinfo *) (handle->opaque))->curPos);
} /* GRP_tell */
***************
*** 160,168 ****
{
GRPfileinfo *finfo = (GRPfileinfo *) (handle->opaque);
! PHYSFS_uint64 newPos = (finfo->startPos + offset);
BAIL_IF_MACRO(offset < 0, ERR_INVALID_ARGUMENT, 0);
! BAIL_IF_MACRO(newPos > finfo->startPos + finfo->size, ERR_PAST_EOF, 0);
! return(__PHYSFS_platformSeek(finfo->handle, newPos));
} /* GRP_seek */
--- 179,193 ----
{
GRPfileinfo *finfo = (GRPfileinfo *) (handle->opaque);
! GRPentry *entry = finfo->entry;
! PHYSFS_uint64 newPos = (entry->startPos + offset);
! int rc;
BAIL_IF_MACRO(offset < 0, ERR_INVALID_ARGUMENT, 0);
! BAIL_IF_MACRO(newPos > entry->startPos + entry->size, ERR_PAST_EOF, 0);
! rc = __PHYSFS_platformSeek(finfo->handle, newPos);
! if (rc)
! finfo->curPos = offset;
!
! return(rc);
} /* GRP_seek */
***************
*** 170,175 ****
static PHYSFS_sint64 GRP_fileLength(FileHandle *handle)
{
! GRPfileinfo *finfo = (GRPfileinfo *) (handle->opaque);
! return(finfo->size);
} /* GRP_fileLength */
--- 195,199 ----
static PHYSFS_sint64 GRP_fileLength(FileHandle *handle)
{
! return(((GRPfileinfo *) handle->opaque)->entry->size);
} /* GRP_fileLength */
***************
*** 177,184 ****
static int GRP_fileClose(FileHandle *handle)
{
! GRPfileinfo *finfo = (GRPfileinfo *) (handle->opaque);
! BAIL_IF_MACRO(__PHYSFS_platformClose(finfo->handle), NULL, 0);
!
! free(handle->opaque);
free(handle);
return(1);
--- 201,207 ----
static int GRP_fileClose(FileHandle *handle)
{
! GRPfileinfo *finfo = ((GRPfileinfo *) handle->opaque);
! BAIL_IF_MACRO(!__PHYSFS_platformClose(finfo->handle), NULL, 0);
! free(finfo);
free(handle);
return(1);
***************
*** 186,191 ****
! static int openGrp(const char *filename, int forWriting,
! void **fh, PHYSFS_sint32 *count)
{
PHYSFS_uint8 buf[12];
--- 209,214 ----
! static int grp_open(const char *filename, int forWriting,
! void **fh, PHYSFS_uint32 *count)
{
PHYSFS_uint8 buf[12];
***************
*** 206,213 ****
} /* if */
! if (__PHYSFS_platformRead(*fh, count, sizeof (PHYSFS_sint32), 1) != 1)
goto openGrp_failed;
! *count = PHYSFS_swapSLE32(*count);
return(1);
--- 229,236 ----
} /* if */
! if (__PHYSFS_platformRead(*fh, count, sizeof (PHYSFS_uint32), 1) != 1)
goto openGrp_failed;
! *count = PHYSFS_swapULE32(*count);
return(1);
***************
*** 220,224 ****
*fh = NULL;
return(0);
! } /* openGrp */
--- 243,247 ----
*fh = NULL;
return(0);
! } /* grp_open */
***************
*** 226,231 ****
{
void *fh;
! int fileCount;
! int retval = openGrp(filename, forWriting, &fh, &fileCount);
if (fh != NULL)
--- 249,254 ----
{
void *fh;
! PHYSFS_uint32 fileCount;
! int retval = grp_open(filename, forWriting, &fh, &fileCount);
if (fh != NULL)
***************
*** 236,248 ****
! static DirHandle *GRP_openArchive(const char *name, int forWriting)
{
void *fh = NULL;
! int fileCount;
DirHandle *retval = malloc(sizeof (DirHandle));
BAIL_IF_MACRO(retval == NULL, ERR_OUT_OF_MEMORY, NULL);
! retval->opaque = malloc(sizeof (GRPinfo));
! if (retval->opaque == NULL)
{
__PHYSFS_setError(ERR_OUT_OF_MEMORY);
--- 259,394 ----
! static void grp_entry_swap(GRPentry *a, PHYSFS_uint32 one, PHYSFS_uint32 two)
! {
! GRPentry tmp;
! memcpy(&tmp, &a[one], sizeof (GRPentry));
! memcpy(&a[one], &a[two], sizeof (GRPentry));
! memcpy(&a[two], &tmp, sizeof (GRPentry));
! } /* grp_entry_swap */
!
!
! static void grp_quick_sort(GRPentry *a, PHYSFS_uint32 lo, PHYSFS_uint32 hi)
! {
! PHYSFS_uint32 i;
! PHYSFS_uint32 j;
! GRPentry *v;
!
! if ((hi - lo) > GRP_QUICKSORT_THRESHOLD)
! {
! i = (hi + lo) / 2;
!
! if (strcmp(a[lo].name, a[i].name) > 0) grp_entry_swap(a, lo, i);
! if (strcmp(a[lo].name, a[hi].name) > 0) grp_entry_swap(a, lo,
hi);
! if (strcmp(a[i].name, a[hi].name) > 0) grp_entry_swap(a, i, hi);
!
! j = hi - 1;
! grp_entry_swap(a, i, j);
! i = lo;
! v = &a[j];
! while (1)
! {
! while(strcmp(a[++i].name, v->name) < 0) {}
! while(strcmp(a[--j].name, v->name) > 0) {}
! if (j < i)
! break;
! grp_entry_swap(a, i, j);
! } /* while */
! grp_entry_swap(a, i, hi-1);
! grp_quick_sort(a, lo, j);
! grp_quick_sort(a, i+1, hi);
! } /* if */
! } /* grp_quick_sort */
!
!
! static void grp_insertion_sort(GRPentry *a, PHYSFS_uint32 lo, PHYSFS_uint32
hi)
! {
! PHYSFS_uint32 i;
! PHYSFS_uint32 j;
! GRPentry tmp;
!
! for (i = lo + 1; i <= hi; i++)
! {
! memcpy(&tmp, &a[i], sizeof (GRPentry));
! j = i;
! while ((j > lo) && (strcmp(a[j - 1].name, tmp.name) > 0))
! {
! memcpy(&a[j], &a[j - 1], sizeof (GRPentry));
! j--;
! } /* while */
! memcpy(&a[j], &tmp, sizeof (GRPentry));
! } /* for */
! } /* grp_insertion_sort */
!
!
! static void grp_sort_entries(GRPentry *entries, PHYSFS_uint32 max)
! {
! /*
! * Fast Quicksort algorithm inspired by code from here:
! * http://www.cs.ubc.ca/spider/harrison/Java/sorting-demo.html
! */
! if (max <= GRP_QUICKSORT_THRESHOLD)
! grp_quick_sort(entries, 0, max - 1);
! grp_insertion_sort(entries, 0, max - 1);
! } /* grp_sort_entries */
!
!
! static int grp_load_entries(const char *name, int forWriting, GRPinfo *info)
{
void *fh = NULL;
! PHYSFS_uint32 fileCount;
! PHYSFS_uint32 location = 16; /* sizeof sig. */
! GRPentry *entry;
! char *ptr;
!
! BAIL_IF_MACRO(!grp_open(name, forWriting, &fh, &fileCount), NULL, 0);
! info->entryCount = fileCount;
! info->entries = (GRPentry *) malloc(sizeof (GRPentry) * fileCount);
! if (info->entries == NULL)
! {
! __PHYSFS_platformClose(fh);
! BAIL_MACRO(ERR_OUT_OF_MEMORY, 0);
! } /* if */
!
! location += (16 * fileCount);
!
! for (entry = info->entries; fileCount > 0; fileCount--, entry++)
! {
! if (__PHYSFS_platformRead(fh, &entry->name, 12, 1) != 1)
! {
! __PHYSFS_platformClose(fh);
! return(0);
! } /* if */
!
! entry->name[12] = '\0'; /* name isn't null-terminated in file. */
! if ((ptr = strchr(entry->name, ' ')) != NULL)
! *ptr = '\0'; /* trim extra spaces. */
!
! if (__PHYSFS_platformRead(fh, &entry->size, 4, 1) != 1)
! {
! __PHYSFS_platformClose(fh);
! return(0);
! } /* if */
!
! entry->size = PHYSFS_swapULE32(entry->size);
! entry->startPos = location;
! location += entry->size;
! } /* for */
!
! __PHYSFS_platformClose(fh);
!
! grp_sort_entries(info->entries, info->entryCount);
! return(1);
! } /* grp_load_entries */
!
!
! static DirHandle *GRP_openArchive(const char *name, int forWriting)
! {
! GRPinfo *info;
DirHandle *retval = malloc(sizeof (DirHandle));
+ PHYSFS_sint64 modtime = __PHYSFS_platformGetLastModTime(name);
BAIL_IF_MACRO(retval == NULL, ERR_OUT_OF_MEMORY, NULL);
! info = retval->opaque = malloc(sizeof (GRPinfo));
! if (info == NULL)
{
__PHYSFS_setError(ERR_OUT_OF_MEMORY);
***************
*** 250,255 ****
} /* if */
! ((GRPinfo *) retval->opaque)->filename = (char *) malloc(strlen(name) +
1);
! if (((GRPinfo *) retval->opaque)->filename == NULL)
{
__PHYSFS_setError(ERR_OUT_OF_MEMORY);
--- 396,403 ----
} /* if */
! memset(info, '\0', sizeof (GRPinfo));
!
! info->filename = (char *) malloc(strlen(name) + 1);
! if (info->filename == NULL)
{
__PHYSFS_setError(ERR_OUT_OF_MEMORY);
***************
*** 257,266 ****
} /* if */
! if (!openGrp(name, forWriting, &fh, &fileCount))
goto GRP_openArchive_failed;
! strcpy(((GRPinfo *) retval->opaque)->filename, name);
! ((GRPinfo *) retval->opaque)->handle = fh;
! ((GRPinfo *) retval->opaque)->totalEntries = fileCount;
retval->funcs = &__PHYSFS_DirFunctions_GRP;
return(retval);
--- 405,413 ----
} /* if */
! if (!grp_load_entries(name, forWriting, info))
goto GRP_openArchive_failed;
! strcpy(info->filename, name);
! info->last_mod_time = modtime;
retval->funcs = &__PHYSFS_DirFunctions_GRP;
return(retval);
***************
*** 271,284 ****
if (retval->opaque != NULL)
{
! if ( ((GRPinfo *) retval->opaque)->filename != NULL )
! free( ((GRPinfo *) retval->opaque)->filename );
! free(retval->opaque);
} /* if */
free(retval);
} /* if */
- if (fh != NULL)
- __PHYSFS_platformClose(fh);
-
return(NULL);
} /* GRP_openArchive */
--- 418,430 ----
if (retval->opaque != NULL)
{
! if (info->filename != NULL)
! free(info->filename);
! if (info->entries != NULL)
! free(info->entries);
! free(info);
} /* if */
free(retval);
} /* if */
return(NULL);
} /* GRP_openArchive */
***************
*** 289,334 ****
int omitSymLinks)
{
! PHYSFS_uint8 buf[16];
! GRPinfo *g = (GRPinfo *) (h->opaque);
! void *fh = g->handle;
PHYSFS_uint32 i;
- LinkedStringList *retval = NULL;
- LinkedStringList *l = NULL;
- LinkedStringList *prev = NULL;
! /* !!! FIXME: Does this consider "/" ? */
! if (*dirname != '\0') /* no directories in GRP files. */
! return(NULL);
!
! /* jump to first file entry... */
! BAIL_IF_MACRO(!__PHYSFS_platformSeek(fh, 16), NULL, NULL);
!
! for (i = 0; i < g->totalEntries; i++)
! {
! BAIL_IF_MACRO(__PHYSFS_platformRead(fh, buf, 16, 1) != 1, NULL,
retval);
! buf[12] = '\0'; /* FILENAME.EXT is all you get. */
!
! l = (LinkedStringList *) malloc(sizeof (LinkedStringList));
! if (l == NULL)
! break;
!
! l->str = (char *) malloc(strlen((const char *) buf) + 1);
! if (l->str == NULL)
! {
! free(l);
! break;
! } /* if */
!
! strcpy(l->str, (const char *) buf);
!
! if (retval == NULL)
! retval = l;
! else
! prev->next = l;
!
! prev = l;
! l->next = NULL;
! } /* for */
return(retval);
--- 435,449 ----
int omitSymLinks)
{
! GRPinfo *info = ((GRPinfo *) h->opaque);
! GRPentry *entry = info->entries;
! LinkedStringList *retval = NULL, *p = NULL;
! PHYSFS_uint32 max = info->entryCount;
PHYSFS_uint32 i;
! /* no directories in GRP files. */
! BAIL_IF_MACRO(*dirname != '\0', ERR_NOT_A_DIR, NULL);
! for (i = 0; i < max; i++, entry++)
! retval = __PHYSFS_addToLinkedStringList(retval, &p, entry->name, -1);
return(retval);
***************
*** 336,390 ****
! static PHYSFS_sint32 getFileEntry(DirHandle *h, const char *name,
! PHYSFS_uint32 *size)
{
! PHYSFS_uint8 buf[16];
! GRPinfo *g = (GRPinfo *) (h->opaque);
! void *fh = g->handle;
! PHYSFS_uint32 i;
! char *ptr;
! int retval = (g->totalEntries + 1) * 16; /* offset of raw file data */
!
! /* Rule out filenames to avoid unneeded file i/o... */
! if (strchr(name, '/') != NULL) /* no directories in groupfiles. */
! return(-1);
!
! ptr = strchr(name, '.');
! if ((ptr) && (strlen(ptr) > 4)) /* 3 char extension at most. */
! return(-1);
!
! if (strlen(name) > 12)
! return(-1);
! /* jump to first file entry... */
! BAIL_IF_MACRO(!__PHYSFS_platformSeek(fh, 16), NULL, -1);
!
! for (i = 0; i < g->totalEntries; i++)
{
! PHYSFS_sint32 l = 0;
!
! BAIL_IF_MACRO(__PHYSFS_platformRead(fh, buf, 12, 1) != 1, NULL, -1);
! BAIL_IF_MACRO(__PHYSFS_platformRead(fh, &l, sizeof (l), 1) != 1,
NULL, -1);
! l = PHYSFS_swapSLE32(l);
!
! buf[12] = '\0'; /* FILENAME.EXT is all you get. */
!
! if (__PHYSFS_platformStricmp((const char *) buf, name) == 0)
! {
! if (size != NULL)
! *size = l;
! return(retval);
! } /* if */
!
! retval += l;
! } /* for */
! return(-1); /* not found. */
! } /* getFileEntry */
static int GRP_exists(DirHandle *h, const char *name)
{
! return(getFileEntry(h, name, NULL) != -1);
} /* GRP_exists */
--- 451,490 ----
! static GRPentry *grp_find_entry(GRPinfo *info, const char *name)
{
! char *ptr = strchr(name, '.');
! GRPentry *a = info->entries;
! PHYSFS_sint32 lo = 0;
! PHYSFS_sint32 hi = (PHYSFS_sint32) (info->entryCount - 1);
! PHYSFS_sint32 middle;
! int rc;
!
! /*
! * Rule out filenames to avoid unneeded processing...no dirs,
! * big filenames, or extensions > 3 chars.
! */
! BAIL_IF_MACRO((ptr) && (strlen(ptr) > 4), ERR_NO_SUCH_FILE, NULL);
! BAIL_IF_MACRO(strlen(name) > 12, ERR_NO_SUCH_FILE, NULL);
! BAIL_IF_MACRO(strchr(name, '/') != NULL, ERR_NO_SUCH_FILE, NULL);
! while (lo <= hi)
{
! middle = lo + ((hi - lo) / 2);
! rc = strcmp(name, a[middle].name);
! if (rc == 0) /* found it! */
! return(&a[middle]);
! else if (rc > 0)
! lo = middle + 1;
! else
! hi = middle - 1;
! } /* while */
! BAIL_MACRO(ERR_NO_SUCH_FILE, NULL);
! } /* grp_find_entry */
static int GRP_exists(DirHandle *h, const char *name)
{
! return(grp_find_entry(((GRPinfo *) h->opaque), name) != NULL);
} /* GRP_exists */
***************
*** 402,415 ****
static FileHandle *GRP_openRead(DirHandle *h, const char *name)
{
! const char *filename = ((GRPinfo *) h->opaque)->filename;
FileHandle *retval;
GRPfileinfo *finfo;
! PHYSFS_uint32 size;
! PHYSFS_sint32 offset;
! offset = getFileEntry(h, name, &size);
! BAIL_IF_MACRO(offset == -1, ERR_NO_SUCH_FILE, NULL);
retval = (FileHandle *) malloc(sizeof (FileHandle));
--- 502,525 ----
+ static PHYSFS_sint64 GRP_getLastModTime(DirHandle *h, const char *name)
+ {
+ GRPinfo *info = ((GRPinfo *) h->opaque);
+ if (grp_find_entry(info, name) == NULL)
+ return(-1); /* no such entry. */
+
+ /* Just return the time of the GRP itself in the physical filesystem. */
+ return(((GRPinfo *) h->opaque)->last_mod_time);
+ } /* GRP_getLastModTime */
+
+
static FileHandle *GRP_openRead(DirHandle *h, const char *name)
{
! GRPinfo *info = ((GRPinfo *) h->opaque);
FileHandle *retval;
GRPfileinfo *finfo;
! GRPentry *entry;
! entry = grp_find_entry(info, name);
! BAIL_IF_MACRO(entry == NULL, NULL, NULL);
retval = (FileHandle *) malloc(sizeof (FileHandle));
***************
*** 419,428 ****
{
free(retval);
! BAIL_IF_MACRO(1, ERR_OUT_OF_MEMORY, NULL);
} /* if */
! finfo->handle = __PHYSFS_platformOpenRead(filename);
if ( (finfo->handle == NULL) ||
! (!__PHYSFS_platformSeek(finfo->handle, offset)) )
{
free(finfo);
--- 529,538 ----
{
free(retval);
! BAIL_MACRO(ERR_OUT_OF_MEMORY, NULL);
} /* if */
! finfo->handle = __PHYSFS_platformOpenRead(info->filename);
if ( (finfo->handle == NULL) ||
! (!__PHYSFS_platformSeek(finfo->handle, entry->startPos)) )
{
free(finfo);
***************
*** 431,436 ****
} /* if */
! finfo->startPos = offset;
! finfo->size = size;
retval->opaque = (void *) finfo;
retval->funcs = &__PHYSFS_FileFunctions_GRP;
--- 541,546 ----
} /* if */
! finfo->curPos = 0;
! finfo->entry = entry;
retval->opaque = (void *) finfo;
retval->funcs = &__PHYSFS_FileFunctions_GRP;
***************
*** 438,441 ****
--- 548,553 ----
return(retval);
} /* GRP_openRead */
+
+ #endif /* defined PHYSFS_SUPPORTS_GRP */
/* end of grp.c ... */
Index: unzip.c
===================================================================
RCS file: /cvsroot/paragui/paragui/src/physfs/archivers/unzip.c,v
retrieving revision 1.2
retrieving revision 1.2.2.1
diff -C2 -r1.2 -r1.2.2.1
*** unzip.c 27 Apr 2002 16:06:26 -0000 1.2
--- unzip.c 31 Aug 2002 04:01:23 -0000 1.2.2.1
***************
*** 5,8 ****
--- 5,13 ----
*/
+ #if HAVE_CONFIG_H
+ # include <config.h>
+ #endif
+
+ #if (defined PHYSFS_SUPPORTS_ZIP)
#include <stdio.h>
***************
*** 15,22 ****
#include "physfs_internal.h"
- #if (!defined PHYSFS_SUPPORTS_ZIP)
- #error PHYSFS_SUPPORTS_ZIP must be defined.
- #endif
-
#ifdef STDC
# include <stddef.h>
--- 20,23 ----
***************
*** 1317,1319 ****
--- 1318,1324 ----
return (int)uReadThis;
}
+
+ #endif /* defined PHYSFS_SUPPORTS_ZIP */
+
+ /* end of unzip.c ... */
Index: zip.c
===================================================================
RCS file: /cvsroot/paragui/paragui/src/physfs/archivers/zip.c,v
retrieving revision 1.2
retrieving revision 1.2.2.1
diff -C2 -r1.2 -r1.2.2.1
*** zip.c 27 Apr 2002 16:06:26 -0000 1.2
--- zip.c 31 Aug 2002 04:01:24 -0000 1.2.2.1
***************
*** 4,19 ****
* Please see the file LICENSE in the source's root directory.
*
! * This file written by Ryan C. Gordon.
*/
! /*
! * !!! FIXME: overall design bugs.
! *
! * Maybe add a seekToStartOfCurrentFile() in unzip.c if complete seek
! * semantics are impossible.
[...2016 lines suppressed...]
ZIPinfo *zi = (ZIPinfo *) (h->opaque);
! freeEntries(zi, zi->global.number_entry, NULL);
free(zi->archiveName);
free(zi);
free(h);
} /* ZIP_dirClose */
/* end of zip.c ... */
--- 1423,1433 ----
{
ZIPinfo *zi = (ZIPinfo *) (h->opaque);
! zip_free_entries(zi->entries, zi->entryCount);
free(zi->archiveName);
free(zi);
free(h);
} /* ZIP_dirClose */
+
+ #endif /* defined PHYSFS_SUPPORTS_ZIP */
/* end of zip.c ... */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [paragui-cvs] CVS: paragui/src/physfs/archivers Makefile.am,1.2,1.2.2.1 dir.c,1.2,1.2.2.1 grp.c,1.2,1.2.2.1 unzip.c,1.2,1.2.2.1 zip.c,1.2,1.2.2.1,
Teunis Peters <address@hidden> <=
- Prev by Date:
[paragui-cvs] CVS: paragui/doc .cvsignore,NONE,1.2.2.1 Makefile.am,NONE,1.2.2.1 RELEASENOTES,NONE,1.2.2.1 VisualC.html,NONE,1.2.2.1
- Next by Date:
[paragui-cvs] CVS: paragui/src/widgets pgbutton.cpp,1.8.2.1,1.8.2.2 pgcolumnitem.cpp,1.3.2.1,1.3.2.2 pgdropdown.cpp,1.8,1.8.2.1 pglayout.cpp,1.2.2.1,1.2.2.2 pglineedit.cpp,1.6.2.1,1.6.2.2 pglistbox.cpp,1.7,1.7.2.1 pglistboxbaseitem.cpp,1.5,1.5.2.1 pglistboxitem.cpp,1.6.2.1,1.6.2.2 pgpopupmenu.cpp,1.7.2.1,1.7.2.2 pgprogressbar.cpp,1.4.2.2,1.4.2.3 pgradiobutton.cpp,1.7,1.7.2.1 pgrichedit.cpp,1.4.2.1,1.4.2.2 pgscrollbar.cpp,1.6.2.1,1.6.2.2 pgtabbar.cpp,1.5,1.5.2.1 pgthemewidget.cpp,1.6.2.1,1.6.2.2 pgwidget.cpp,1.13.2.2,1.13.2.3 pgwidgetlist.cpp,1.11.2.1,1.11.2.2 pgwidgetlistex.cpp,1.4,1.4.2.1 pgwindow.cpp,1.10.2.1,1.10.2.2
- Previous by thread:
[paragui-cvs] CVS: paragui/doc .cvsignore,NONE,1.2.2.1 Makefile.am,NONE,1.2.2.1 RELEASENOTES,NONE,1.2.2.1 VisualC.html,NONE,1.2.2.1
- Next by thread:
[paragui-cvs] CVS: paragui/src/widgets pgbutton.cpp,1.8.2.1,1.8.2.2 pgcolumnitem.cpp,1.3.2.1,1.3.2.2 pgdropdown.cpp,1.8,1.8.2.1 pglayout.cpp,1.2.2.1,1.2.2.2 pglineedit.cpp,1.6.2.1,1.6.2.2 pglistbox.cpp,1.7,1.7.2.1 pglistboxbaseitem.cpp,1.5,1.5.2.1 pglistboxitem.cpp,1.6.2.1,1.6.2.2 pgpopupmenu.cpp,1.7.2.1,1.7.2.2 pgprogressbar.cpp,1.4.2.2,1.4.2.3 pgradiobutton.cpp,1.7,1.7.2.1 pgrichedit.cpp,1.4.2.1,1.4.2.2 pgscrollbar.cpp,1.6.2.1,1.6.2.2 pgtabbar.cpp,1.5,1.5.2.1 pgthemewidget.cpp,1.6.2.1,1.6.2.2 pgwidget.cpp,1.13.2.2,1.13.2.3 pgwidgetlist.cpp,1.11.2.1,1.11.2.2 pgwidgetlistex.cpp,1.4,1.4.2.1 pgwindow.cpp,1.10.2.1,1.10.2.2
- Index(es):