From b58e5f348ce4554e456aa0e461a25c45cd5431db Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Wed, 25 Aug 2010 01:28:28 -0400 Subject: [PATCH] Removed __PHYSFS_platformGetLastModTime(). --- src/archiver_grp.c | 7 ++--- src/archiver_hog.c | 7 ++--- src/archiver_mvl.c | 9 ++---- src/archiver_qpak.c | 9 ++---- src/archiver_wad.c | 9 ++---- src/physfs_internal.h | 8 ------ src/platform_os2.c | 17 ----------- src/platform_pocketpc.c | 6 ---- src/platform_posix.c | 8 ------ src/platform_windows.c | 62 ----------------------------------------- 10 files changed, 13 insertions(+), 129 deletions(-) diff --git a/src/archiver_grp.c b/src/archiver_grp.c index 4df1394d..63df5269 100644 --- a/src/archiver_grp.c +++ b/src/archiver_grp.c @@ -44,7 +44,6 @@ typedef struct typedef struct { char *filename; - PHYSFS_sint64 last_mod_time; PHYSFS_uint32 entryCount; GRPentry *entries; } GRPinfo; @@ -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); @@ -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; @@ -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; diff --git a/src/archiver_hog.c b/src/archiver_hog.c index b2620bdc..562c7439 100644 --- a/src/archiver_hog.c +++ b/src/archiver_hog.c @@ -55,7 +55,6 @@ typedef struct typedef struct { char *filename; - PHYSFS_sint64 last_mod_time; PHYSFS_uint32 entryCount; HOGentry *entries; } HOGinfo; @@ -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); @@ -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; @@ -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; diff --git a/src/archiver_mvl.c b/src/archiver_mvl.c index 28235f4e..bda06726 100644 --- a/src/archiver_mvl.c +++ b/src/archiver_mvl.c @@ -47,7 +47,6 @@ typedef struct typedef struct { char *filename; - PHYSFS_sint64 last_mod_time; PHYSFS_uint32 entryCount; MVLentry *entries; } MVLinfo; @@ -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); @@ -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: @@ -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; diff --git a/src/archiver_qpak.c b/src/archiver_qpak.c index c5ac2a32..6ec742c8 100644 --- a/src/archiver_qpak.c +++ b/src/archiver_qpak.c @@ -58,7 +58,6 @@ typedef struct typedef struct { char *filename; - PHYSFS_sint64 last_mod_time; PHYSFS_uint32 entryCount; QPAKentry *entries; } QPAKinfo; @@ -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)); @@ -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: @@ -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; diff --git a/src/archiver_wad.c b/src/archiver_wad.c index 165c7d42..3524fe2c 100644 --- a/src/archiver_wad.c +++ b/src/archiver_wad.c @@ -62,7 +62,6 @@ typedef struct typedef struct { char *filename; - PHYSFS_sint64 last_mod_time; PHYSFS_uint32 entryCount; PHYSFS_uint32 entryOffset; WADentry *entries; @@ -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); @@ -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: @@ -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; diff --git a/src/physfs_internal.h b/src/physfs_internal.h index dff37651..d24ea839 100644 --- a/src/physfs_internal.h +++ b/src/physfs_internal.h @@ -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. */ diff --git a/src/platform_os2.c b/src/platform_os2.c index 26ce473d..833462ed 100644 --- a/src/platform_os2.c +++ b/src/platform_os2.c @@ -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) { diff --git a/src/platform_pocketpc.c b/src/platform_pocketpc.c index 04cf60b5..736001ab 100644 --- a/src/platform_pocketpc.c +++ b/src/platform_pocketpc.c @@ -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) { diff --git a/src/platform_posix.c b/src/platform_posix.c index 760becc9..346c2fc8 100644 --- a/src/platform_posix.c +++ b/src/platform_posix.c @@ -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; diff --git a/src/platform_windows.c b/src/platform_windows.c index da575087..995bbf5c 100644 --- a/src/platform_windows.c +++ b/src/platform_windows.c @@ -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) {