unpacked: let archivers specify create and modified times, hook up to iso9660.
This commit is contained in:
parent
3c9351c0ad
commit
03097332ca
|
@ -47,7 +47,7 @@ static int grpLoadEntries(PHYSFS_Io *io, const PHYSFS_uint32 count, void *arc)
|
||||||
*ptr = '\0'; /* trim extra spaces. */
|
*ptr = '\0'; /* trim extra spaces. */
|
||||||
|
|
||||||
size = PHYSFS_swapULE32(size);
|
size = PHYSFS_swapULE32(size);
|
||||||
BAIL_IF_ERRPASS(!UNPK_addEntry(arc, name, 0, location, size), 0);
|
BAIL_IF_ERRPASS(!UNPK_addEntry(arc, name, 0, -1, -1, location, size), 0);
|
||||||
|
|
||||||
location += size;
|
location += size;
|
||||||
} /* for */
|
} /* for */
|
||||||
|
|
|
@ -50,7 +50,7 @@ static int hogLoadEntries(PHYSFS_Io *io, void *unpkarc)
|
||||||
pos += 13 + 4;
|
pos += 13 + 4;
|
||||||
|
|
||||||
size = PHYSFS_swapULE32(size);
|
size = PHYSFS_swapULE32(size);
|
||||||
BAIL_IF_ERRPASS(!UNPK_addEntry(unpkarc, name, 0, pos, size), 0);
|
BAIL_IF_ERRPASS(!UNPK_addEntry(unpkarc, name, 0, -1, -1, pos, size), 0);
|
||||||
pos += size;
|
pos += size;
|
||||||
|
|
||||||
/* skip over entry */
|
/* skip over entry */
|
||||||
|
|
|
@ -30,6 +30,8 @@
|
||||||
|
|
||||||
#if PHYSFS_SUPPORTS_ISO9660
|
#if PHYSFS_SUPPORTS_ISO9660
|
||||||
|
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
/* ISO9660 often stores values in both big and little endian formats: little
|
/* ISO9660 often stores values in both big and little endian formats: little
|
||||||
first, followed by big. While technically there might be different values
|
first, followed by big. While technically there might be different values
|
||||||
in each, we just always use the littleendian ones and swap ourselves. The
|
in each, we just always use the littleendian ones and swap ourselves. The
|
||||||
|
@ -42,8 +44,9 @@ static int iso9660LoadEntries(PHYSFS_Io *io, const int joliet,
|
||||||
|
|
||||||
static int iso9660AddEntry(PHYSFS_Io *io, const int joliet, const int isdir,
|
static int iso9660AddEntry(PHYSFS_Io *io, const int joliet, const int isdir,
|
||||||
const char *base, PHYSFS_uint8 *fname,
|
const char *base, PHYSFS_uint8 *fname,
|
||||||
const int fnamelen, const PHYSFS_uint64 pos,
|
const int fnamelen, const PHYSFS_sint64 timestamp,
|
||||||
const PHYSFS_uint64 len, void *unpkarc)
|
const PHYSFS_uint64 pos, const PHYSFS_uint64 len,
|
||||||
|
void *unpkarc)
|
||||||
{
|
{
|
||||||
char *fullpath;
|
char *fullpath;
|
||||||
char *fnamecpy;
|
char *fnamecpy;
|
||||||
|
@ -101,7 +104,8 @@ static int iso9660AddEntry(PHYSFS_Io *io, const int joliet, const int isdir,
|
||||||
} /* if */
|
} /* if */
|
||||||
} /* else */
|
} /* else */
|
||||||
|
|
||||||
entry = UNPK_addEntry(unpkarc, fullpath, isdir, pos, len);
|
entry = UNPK_addEntry(unpkarc, fullpath, isdir,
|
||||||
|
timestamp, timestamp, pos, len);
|
||||||
|
|
||||||
if ((entry) && (isdir))
|
if ((entry) && (isdir))
|
||||||
{
|
{
|
||||||
|
@ -130,6 +134,8 @@ static int iso9660LoadEntries(PHYSFS_Io *io, const int joliet,
|
||||||
PHYSFS_uint8 flags;
|
PHYSFS_uint8 flags;
|
||||||
PHYSFS_uint8 fnamelen;
|
PHYSFS_uint8 fnamelen;
|
||||||
PHYSFS_uint8 fname[256];
|
PHYSFS_uint8 fname[256];
|
||||||
|
PHYSFS_sint64 timestamp;
|
||||||
|
struct tm t;
|
||||||
int isdir;
|
int isdir;
|
||||||
int multiextent;
|
int multiextent;
|
||||||
|
|
||||||
|
@ -177,13 +183,20 @@ static int iso9660LoadEntries(PHYSFS_Io *io, const int joliet,
|
||||||
BAIL_IF_ERRPASS(!__PHYSFS_readAll(io, &fnamelen, 1), 0);
|
BAIL_IF_ERRPASS(!__PHYSFS_readAll(io, &fnamelen, 1), 0);
|
||||||
BAIL_IF_ERRPASS(!__PHYSFS_readAll(io, fname, fnamelen), 0);
|
BAIL_IF_ERRPASS(!__PHYSFS_readAll(io, fname, fnamelen), 0);
|
||||||
|
|
||||||
/* !!! FIXME: we lost timestamps here. Add support into the unpacked
|
t.tm_sec = second;
|
||||||
!!! FIXME: archiver, parse them out here (and parse them out of
|
t.tm_min = minute;
|
||||||
!!! FIXME: extended attributes too?). */
|
t.tm_hour = hour;
|
||||||
|
t.tm_mday = day;
|
||||||
|
t.tm_mon = month - 1;
|
||||||
|
t.tm_year = year;
|
||||||
|
t.tm_wday = 0;
|
||||||
|
t.tm_yday = 0;
|
||||||
|
t.tm_isdst = -1;
|
||||||
|
timestamp = (PHYSFS_sint64) mktime(&t);
|
||||||
|
|
||||||
extent += extattrlen; /* skip extended attribute record. */
|
extent += extattrlen; /* skip extended attribute record. */
|
||||||
if (!iso9660AddEntry(io, joliet, isdir, base, fname, fnamelen,
|
if (!iso9660AddEntry(io, joliet, isdir, base, fname, fnamelen,
|
||||||
extent * 2048, datalen, unpkarc))
|
timestamp, extent * 2048, datalen, unpkarc))
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
} /* if */
|
} /* if */
|
||||||
|
|
|
@ -45,7 +45,7 @@ static int mvlLoadEntries(PHYSFS_Io *io, const PHYSFS_uint32 count, void *arc)
|
||||||
BAIL_IF_ERRPASS(!__PHYSFS_readAll(io, &size, 4), 0);
|
BAIL_IF_ERRPASS(!__PHYSFS_readAll(io, &size, 4), 0);
|
||||||
name[12] = '\0'; /* just in case. */
|
name[12] = '\0'; /* just in case. */
|
||||||
size = PHYSFS_swapULE32(size);
|
size = PHYSFS_swapULE32(size);
|
||||||
BAIL_IF_ERRPASS(!UNPK_addEntry(arc, name, 0, location, size), 0);
|
BAIL_IF_ERRPASS(!UNPK_addEntry(arc, name, 0, -1, -1, location, size), 0);
|
||||||
location += size;
|
location += size;
|
||||||
} /* for */
|
} /* for */
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ static int qpakLoadEntries(PHYSFS_Io *io, const PHYSFS_uint32 count, void *arc)
|
||||||
BAIL_IF_ERRPASS(!__PHYSFS_readAll(io, &size, 4), 0);
|
BAIL_IF_ERRPASS(!__PHYSFS_readAll(io, &size, 4), 0);
|
||||||
size = PHYSFS_swapULE32(size);
|
size = PHYSFS_swapULE32(size);
|
||||||
location = PHYSFS_swapULE32(location);
|
location = PHYSFS_swapULE32(location);
|
||||||
BAIL_IF_ERRPASS(!UNPK_addEntry(arc, name, 0, location, size), 0);
|
BAIL_IF_ERRPASS(!UNPK_addEntry(arc, name, 0, -1, -1, location, size), 0);
|
||||||
} /* for */
|
} /* for */
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -52,7 +52,7 @@ static int slbLoadEntries(PHYSFS_Io *io, const PHYSFS_uint32 count, void *arc)
|
||||||
BAIL_IF_ERRPASS(!__PHYSFS_readAll(io, &size, 4), 0);
|
BAIL_IF_ERRPASS(!__PHYSFS_readAll(io, &size, 4), 0);
|
||||||
size = PHYSFS_swapULE32(size);
|
size = PHYSFS_swapULE32(size);
|
||||||
|
|
||||||
BAIL_IF_ERRPASS(!UNPK_addEntry(arc, name, 0, location, size), 0);
|
BAIL_IF_ERRPASS(!UNPK_addEntry(arc, name, 0, -1, -1, location, size), 0);
|
||||||
} /* for */
|
} /* for */
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -27,6 +27,8 @@ typedef struct
|
||||||
__PHYSFS_DirTreeEntry tree;
|
__PHYSFS_DirTreeEntry tree;
|
||||||
PHYSFS_uint64 startPos;
|
PHYSFS_uint64 startPos;
|
||||||
PHYSFS_uint64 size;
|
PHYSFS_uint64 size;
|
||||||
|
PHYSFS_sint64 ctime;
|
||||||
|
PHYSFS_sint64 mtime;
|
||||||
} UNPKentry;
|
} UNPKentry;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
|
@ -255,8 +257,8 @@ int UNPK_stat(void *opaque, const char *path, PHYSFS_Stat *stat)
|
||||||
stat->filesize = entry->size;
|
stat->filesize = entry->size;
|
||||||
} /* else */
|
} /* else */
|
||||||
|
|
||||||
stat->modtime = -1;
|
stat->modtime = entry->mtime;
|
||||||
stat->createtime = -1;
|
stat->createtime = entry->ctime;
|
||||||
stat->accesstime = -1;
|
stat->accesstime = -1;
|
||||||
stat->readonly = 1;
|
stat->readonly = 1;
|
||||||
|
|
||||||
|
@ -265,6 +267,7 @@ int UNPK_stat(void *opaque, const char *path, PHYSFS_Stat *stat)
|
||||||
|
|
||||||
|
|
||||||
void *UNPK_addEntry(void *opaque, char *name, const int isdir,
|
void *UNPK_addEntry(void *opaque, char *name, const int isdir,
|
||||||
|
const PHYSFS_sint64 ctime, const PHYSFS_sint64 mtime,
|
||||||
const PHYSFS_uint64 pos, const PHYSFS_uint64 len)
|
const PHYSFS_uint64 pos, const PHYSFS_uint64 len)
|
||||||
{
|
{
|
||||||
UNPKinfo *info = (UNPKinfo *) opaque;
|
UNPKinfo *info = (UNPKinfo *) opaque;
|
||||||
|
@ -275,6 +278,8 @@ void *UNPK_addEntry(void *opaque, char *name, const int isdir,
|
||||||
|
|
||||||
entry->startPos = isdir ? 0 : pos;
|
entry->startPos = isdir ? 0 : pos;
|
||||||
entry->size = isdir ? 0 : len;
|
entry->size = isdir ? 0 : len;
|
||||||
|
entry->ctime = ctime;
|
||||||
|
entry->mtime = mtime;
|
||||||
|
|
||||||
return entry;
|
return entry;
|
||||||
} /* UNPK_addEntry */
|
} /* UNPK_addEntry */
|
||||||
|
|
|
@ -63,7 +63,7 @@ static int wadLoadEntries(PHYSFS_Io *io, const PHYSFS_uint32 count, void *arc)
|
||||||
name[8] = '\0'; /* name might not be null-terminated in file. */
|
name[8] = '\0'; /* name might not be null-terminated in file. */
|
||||||
size = PHYSFS_swapULE32(size);
|
size = PHYSFS_swapULE32(size);
|
||||||
location = PHYSFS_swapULE32(location);
|
location = PHYSFS_swapULE32(location);
|
||||||
BAIL_IF_ERRPASS(!UNPK_addEntry(arc, name, 0, location, size), 0);
|
BAIL_IF_ERRPASS(!UNPK_addEntry(arc, name, 0, -1, -1, location, size), 0);
|
||||||
} /* for */
|
} /* for */
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -346,6 +346,7 @@ void UNPK_abandonArchive(void *opaque);
|
||||||
void UNPK_closeArchive(void *opaque);
|
void UNPK_closeArchive(void *opaque);
|
||||||
void *UNPK_openArchive(PHYSFS_Io *io);
|
void *UNPK_openArchive(PHYSFS_Io *io);
|
||||||
void *UNPK_addEntry(void *opaque, char *name, const int isdir,
|
void *UNPK_addEntry(void *opaque, char *name, const int isdir,
|
||||||
|
const PHYSFS_sint64 ctime, const PHYSFS_sint64 mtime,
|
||||||
const PHYSFS_uint64 pos, const PHYSFS_uint64 len);
|
const PHYSFS_uint64 pos, const PHYSFS_uint64 len);
|
||||||
PHYSFS_Io *UNPK_openRead(void *opaque, const char *name);
|
PHYSFS_Io *UNPK_openRead(void *opaque, const char *name);
|
||||||
PHYSFS_Io *UNPK_openWrite(void *opaque, const char *name);
|
PHYSFS_Io *UNPK_openWrite(void *opaque, const char *name);
|
||||||
|
|
Loading…
Reference in New Issue