Skip to content

Commit

Permalink
Removed __PHYSFS_platformGetLastModTime().
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Aug 25, 2010
1 parent 8def2f8 commit b58e5f3
Show file tree
Hide file tree
Showing 10 changed files with 13 additions and 129 deletions.
7 changes: 2 additions & 5 deletions src/archiver_grp.c
Expand Up @@ -44,7 +44,6 @@ typedef struct
typedef struct
{
char *filename;
PHYSFS_sint64 last_mod_time;
PHYSFS_uint32 entryCount;
GRPentry *entries;
} GRPinfo;
Expand Down Expand Up @@ -252,7 +251,6 @@ static int grp_load_entries(const char *name, int forWriting, GRPinfo *info)

static void *GRP_openArchive(const char *name, int forWriting)
{
PHYSFS_sint64 modtime = __PHYSFS_platformGetLastModTime(name);
GRPinfo *info = (GRPinfo *) allocator.Malloc(sizeof (GRPinfo));

BAIL_IF_MACRO(info == NULL, ERR_OUT_OF_MEMORY, 0);
Expand All @@ -265,7 +263,6 @@ static void *GRP_openArchive(const char *name, int forWriting)
goto GRP_openArchive_failed;

strcpy(info->filename, name);
info->last_mod_time = modtime;

return info;

Expand Down Expand Up @@ -417,8 +414,8 @@ static int GRP_stat(dvoid *opaque, const char *filename, int *exists,

stat->filesize = entry->size;
stat->filetype = PHYSFS_FILETYPE_REGULAR;
stat->modtime = info->last_mod_time;
stat->createtime = info->last_mod_time;
stat->modtime = -1;
stat->createtime = -1;
stat->accesstime = -1;
stat->readonly = 1;

Expand Down
7 changes: 2 additions & 5 deletions src/archiver_hog.c
Expand Up @@ -55,7 +55,6 @@ typedef struct
typedef struct
{
char *filename;
PHYSFS_sint64 last_mod_time;
PHYSFS_uint32 entryCount;
HOGentry *entries;
} HOGinfo;
Expand Down Expand Up @@ -288,7 +287,6 @@ static int hog_load_entries(const char *name, int forWriting, HOGinfo *info)

static void *HOG_openArchive(const char *name, int forWriting)
{
PHYSFS_sint64 modtime = __PHYSFS_platformGetLastModTime(name);
HOGinfo *info = (HOGinfo *) allocator.Malloc(sizeof (HOGinfo));

BAIL_IF_MACRO(info == NULL, ERR_OUT_OF_MEMORY, NULL);
Expand All @@ -300,7 +298,6 @@ static void *HOG_openArchive(const char *name, int forWriting)
goto HOG_openArchive_failed;

strcpy(info->filename, name);
info->last_mod_time = modtime;

return info;

Expand Down Expand Up @@ -452,8 +449,8 @@ static int HOG_stat(dvoid *opaque, const char *filename, int *exists,

stat->filesize = entry->size;
stat->filetype = PHYSFS_FILETYPE_REGULAR;
stat->modtime = info->last_mod_time;
stat->createtime = info->last_mod_time;
stat->modtime = -1;
stat->createtime = -1;
stat->accesstime = -1;
stat->readonly = 1;

Expand Down
9 changes: 3 additions & 6 deletions src/archiver_mvl.c
Expand Up @@ -47,7 +47,6 @@ typedef struct
typedef struct
{
char *filename;
PHYSFS_sint64 last_mod_time;
PHYSFS_uint32 entryCount;
MVLentry *entries;
} MVLinfo;
Expand Down Expand Up @@ -249,7 +248,6 @@ static int mvl_load_entries(const char *name, int forWriting, MVLinfo *info)

static void *MVL_openArchive(const char *name, int forWriting)
{
PHYSFS_sint64 modtime = __PHYSFS_platformGetLastModTime(name);
MVLinfo *info = (MVLinfo *) allocator.Malloc(sizeof (MVLinfo));

BAIL_IF_MACRO(info == NULL, ERR_OUT_OF_MEMORY, NULL);
Expand All @@ -261,7 +259,6 @@ static void *MVL_openArchive(const char *name, int forWriting)
goto MVL_openArchive_failed;

strcpy(info->filename, name);
info->last_mod_time = modtime;
return info;

MVL_openArchive_failed:
Expand Down Expand Up @@ -412,9 +409,9 @@ static int MVL_stat(dvoid *opaque, const char *filename, int *exists,

stat->filesize = entry->size;
stat->filetype = PHYSFS_FILETYPE_REGULAR;
stat->modtime = info->last_mod_time;
stat->createtime = info->last_mod_time;
stat->accesstime = 0;
stat->modtime = -1;
stat->createtime = -1;
stat->accesstime = -1;
stat->readonly = 1;

return 1;
Expand Down
9 changes: 3 additions & 6 deletions src/archiver_qpak.c
Expand Up @@ -58,7 +58,6 @@ typedef struct
typedef struct
{
char *filename;
PHYSFS_sint64 last_mod_time;
PHYSFS_uint32 entryCount;
QPAKentry *entries;
} QPAKinfo;
Expand Down Expand Up @@ -270,7 +269,6 @@ static int qpak_load_entries(const char *name, int forWriting, QPAKinfo *info)
static void *QPAK_openArchive(const char *name, int forWriting)
{
QPAKinfo *info = (QPAKinfo *) allocator.Malloc(sizeof (QPAKinfo));
PHYSFS_sint64 modtime = __PHYSFS_platformGetLastModTime(name);

BAIL_IF_MACRO(info == NULL, ERR_OUT_OF_MEMORY, NULL);
memset(info, '\0', sizeof (QPAKinfo));
Expand All @@ -286,7 +284,6 @@ static void *QPAK_openArchive(const char *name, int forWriting)
goto QPAK_openArchive_failed;

strcpy(info->filename, name);
info->last_mod_time = modtime;
return info;

QPAK_openArchive_failed:
Expand Down Expand Up @@ -573,9 +570,9 @@ static int QPAK_stat(dvoid *opaque, const char *filename, int *exists,
stat->filesize = entry->size;
} /* else */

stat->modtime = info->last_mod_time;
stat->createtime = info->last_mod_time;
stat->accesstime = 0;
stat->modtime = -1;
stat->createtime = -1;
stat->accesstime = -1;
stat->readonly = 1;

return 1;
Expand Down
9 changes: 3 additions & 6 deletions src/archiver_wad.c
Expand Up @@ -62,7 +62,6 @@ typedef struct
typedef struct
{
char *filename;
PHYSFS_sint64 last_mod_time;
PHYSFS_uint32 entryCount;
PHYSFS_uint32 entryOffset;
WADentry *entries;
Expand Down Expand Up @@ -275,7 +274,6 @@ static int wad_load_entries(const char *name, int forWriting, WADinfo *info)

static void *WAD_openArchive(const char *name, int forWriting)
{
PHYSFS_sint64 modtime = __PHYSFS_platformGetLastModTime(name);
WADinfo *info = (WADinfo *) allocator.Malloc(sizeof (WADinfo));

BAIL_IF_MACRO(info == NULL, ERR_OUT_OF_MEMORY, NULL);
Expand All @@ -288,7 +286,6 @@ static void *WAD_openArchive(const char *name, int forWriting)
goto WAD_openArchive_failed;

strcpy(info->filename, name);
info->last_mod_time = modtime;
return info;

WAD_openArchive_failed:
Expand Down Expand Up @@ -471,9 +468,9 @@ static int WAD_stat(dvoid *opaque, const char *filename, int *exists,

stat->filesize = entry->size;
stat->filetype = PHYSFS_FILETYPE_REGULAR;
stat->accesstime = 0;
stat->modtime = ((WADinfo *) opaque)->last_mod_time;
stat->createtime = ((WADinfo *) opaque)->last_mod_time;
stat->accesstime = -1;
stat->modtime = -1;
stat->createtime = -1;
stat->readonly = 1; /* WADs are always readonly */

return 1;
Expand Down
8 changes: 0 additions & 8 deletions src/physfs_internal.h
Expand Up @@ -1326,14 +1326,6 @@ void *__PHYSFS_platformGetThreadID(void);
*/
int __PHYSFS_platformExists(const char *fname);

/*
* Return the last modified time (in seconds since the epoch) of a file.
* Returns -1 on failure. (fname) is in platform-dependent notation.
* Symlinks should be followed; if what the symlink points to is missing,
* then the retval is -1.
*/
PHYSFS_sint64 __PHYSFS_platformGetLastModTime(const char *fname);

/*
* Return non-zero if filename (in platform-dependent notation) is a symlink.
*/
Expand Down
17 changes: 0 additions & 17 deletions src/platform_os2.c
Expand Up @@ -625,23 +625,6 @@ PHYSFS_sint64 os2TimeToUnixTime(const FDATE *date, const FTIME *time)
} /* os2TimeToUnixTime */


PHYSFS_sint64 __PHYSFS_platformGetLastModTime(const char *_fname)
{
const unsigned char *fname = (const unsigned char *) _fname;
PHYSFS_sint64 retval;
struct tm tm;
FILESTATUS3 fs;
APIRET rc = DosQueryPathInfo(fname, FIL_STANDARD, &fs, sizeof (fs));
BAIL_IF_MACRO(os2err(rc) != NO_ERROR, NULL, -1);

/* Convert to a format PhysicsFS can grok... */
retval = os2TimeToUnixTime(&fs.fdateLastWrite, &fs.ftimeLastWrite);

BAIL_IF_MACRO(retval == -1, strerror(errno), -1);
return retval;
} /* __PHYSFS_platformGetLastModTime */


static int __PHYSFS_platformStat(const char *_fname, int *exists,
PHYSFS_Stat *stat)
{
Expand Down
6 changes: 0 additions & 6 deletions src/platform_pocketpc.c
Expand Up @@ -664,12 +664,6 @@ void __PHYSFS_platformReleaseMutex(void *mutex)
} /* __PHYSFS_platformReleaseMutex */


PHYSFS_sint64 __PHYSFS_platformGetLastModTime(const char *fname)
{
BAIL_MACRO(ERR_NOT_IMPLEMENTED, -1);
} /* __PHYSFS_platformGetLastModTime */


/* !!! FIXME: Don't use C runtime for allocators? */
int __PHYSFS_platformSetDefaultAllocator(PHYSFS_Allocator *a)
{
Expand Down
8 changes: 0 additions & 8 deletions src/platform_posix.c
Expand Up @@ -409,14 +409,6 @@ int __PHYSFS_platformDelete(const char *path)
} /* __PHYSFS_platformDelete */


PHYSFS_sint64 __PHYSFS_platformGetLastModTime(const char *fname)
{
struct stat statbuf;
BAIL_IF_MACRO(stat(fname, &statbuf) < 0, strerror(errno), -1);
return statbuf.st_mtime;
} /* __PHYSFS_platformGetLastModTime */


int __PHYSFS_platformStat(const char *filename, int *exists, PHYSFS_Stat *st)
{
struct stat statbuf;
Expand Down
62 changes: 0 additions & 62 deletions src/platform_windows.c
Expand Up @@ -1305,68 +1305,6 @@ static PHYSFS_sint64 FileTimeToPhysfsTime(const FILETIME *ft)
} /* FileTimeToPhysfsTime */


PHYSFS_sint64 __PHYSFS_platformGetLastModTime(const char *fname)
{
PHYSFS_sint64 retval = -1;
WIN32_FILE_ATTRIBUTE_DATA attr;
int rc = 0;

memset(&attr, '\0', sizeof (attr));

/* GetFileAttributesEx didn't show up until Win98 and NT4. */
if ((pGetFileAttributesExW != NULL) || (pGetFileAttributesExA != NULL))
{
WCHAR *wstr;
UTF8_TO_UNICODE_STACK_MACRO(wstr, fname);
if (wstr != NULL) /* if NULL, maybe the fallback will work. */
{
if (pGetFileAttributesExW != NULL) /* NT/XP/Vista/etc system. */
rc = pGetFileAttributesExW(wstr, GetFileExInfoStandard, &attr);
else /* Win98/ME system */
{
const int len = (int) (wStrLen(wstr) + 1);
char *cp = (char *) __PHYSFS_smallAlloc(len);
if (cp != NULL)
{
WideCharToMultiByte(CP_ACP, 0, wstr, len, cp, len, 0, 0);
rc = pGetFileAttributesExA(cp, GetFileExInfoStandard, &attr);
__PHYSFS_smallFree(cp);
} /* if */
} /* else */
__PHYSFS_smallFree(wstr);
} /* if */
} /* if */

if (rc) /* had API entry point and it worked. */
{
/* 0 return value indicates an error or not supported */
if ( (attr.ftLastWriteTime.dwHighDateTime != 0) ||
(attr.ftLastWriteTime.dwLowDateTime != 0) )
{
retval = FileTimeToPhysfsTime(&attr.ftLastWriteTime);
} /* if */
} /* if */

/* GetFileTime() has been in the Win32 API since the start. */
if (retval == -1) /* try a fallback... */
{
FILETIME ft;
BOOL rc;
const char *err;
WinApiFile *f = (WinApiFile *) __PHYSFS_platformOpenRead(fname);
BAIL_IF_MACRO(f == NULL, NULL, -1)
rc = GetFileTime(f->handle, NULL, NULL, &ft);
err = winApiStrError();
CloseHandle(f->handle);
allocator.Free(f);
BAIL_IF_MACRO(!rc, err, -1);
retval = FileTimeToPhysfsTime(&ft);
} /* if */

return retval;
} /* __PHYSFS_platformGetLastModTime */


static int __PHYSFS_platformStatOldWay(const char *filename, int *exists,
PHYSFS_Stat *stat)
{
Expand Down

0 comments on commit b58e5f3

Please sign in to comment.