Skip to content

Commit

Permalink
Implemeted getLastModTime method.
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Jun 6, 2002
1 parent b0d5683 commit 05b5654
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion archivers/zip.c
Expand Up @@ -26,6 +26,7 @@
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <time.h>
#include "physfs.h"
#include "unzip.h"

Expand Down Expand Up @@ -75,6 +76,7 @@ static LinkedStringList *ZIP_enumerateFiles(DirHandle *h,
static int ZIP_exists(DirHandle *h, const char *name);
static int ZIP_isDirectory(DirHandle *h, const char *name);
static int ZIP_isSymLink(DirHandle *h, const char *name);
static PHYSFS_sint64 ZIP_getLastModTime(DirHandle *h, const char *name);
static FileHandle *ZIP_openRead(DirHandle *h, const char *filename);
static void ZIP_dirClose(DirHandle *h);

Expand All @@ -99,7 +101,7 @@ const DirFunctions __PHYSFS_DirFunctions_ZIP =
ZIP_exists, /* exists() method */
ZIP_isDirectory, /* isDirectory() method */
ZIP_isSymLink, /* isSymLink() method */
NULL, /* getLastModTime() method */ /* !!! FIXME: This can be determined in a zipfile. */
ZIP_getLastModTime, /* getLastModTime() method */
ZIP_openRead, /* openRead() method */
NULL, /* openWrite() method */
NULL, /* openAppend() method */
Expand Down Expand Up @@ -581,6 +583,32 @@ static int ZIP_exists(DirHandle *h, const char *name)
} /* ZIP_exists */


static PHYSFS_sint64 ZIP_getLastModTime(DirHandle *h, const char *name)
{
ZIPinfo *zi = (ZIPinfo *) (h->opaque);
int pos = ZIP_exists_symcheck(h, name, SYMLINK_RECURSE_COUNT);
ZIPentry *entry;
struct tm t;

if (pos == -1)
return(0);

entry = &zi->entries[pos];

/* if it's a symlink, then we ran into a possible symlink loop. */
BAIL_IF_MACRO(entry->symlink != NULL, ERR_TOO_MANY_SYMLINKS, 0);

memset(&t, '\0', sizeof (t));
t.tm_year = entry->info.tmu_date.tm_year - 1900;
t.tm_mon = entry->info.tmu_date.tm_mon;
t.tm_mday = entry->info.tmu_date.tm_mday;
t.tm_hour = entry->info.tmu_date.tm_hour;
t.tm_min = entry->info.tmu_date.tm_min;
t.tm_sec = entry->info.tmu_date.tm_sec;
return((PHYSFS_sint64) mktime(&t));
} /* ZIP_getLastModTime */


static int ZIP_isDirectory(DirHandle *h, const char *name)
{
int dlen;
Expand Down

0 comments on commit 05b5654

Please sign in to comment.