Skip to content

Commit

Permalink
Added getlastmodtime command.
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed May 25, 2002
1 parent eac8979 commit 9bcd3c1
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions test/test_physfs.c
Expand Up @@ -25,6 +25,8 @@
#include <readline/history.h>
#endif

#include <time.h>

#include "physfs.h"

#define TEST_VERSION_MAJOR 0
Expand Down Expand Up @@ -557,6 +559,31 @@ static int cmd_write(char *args)
} /* cmd_write */


static void modTimeToStr(PHYSFS_sint64 modtime, char *modstr, size_t strsize)
{
time_t t = (time_t) modtime;
char *str = ctime(&t);
strncpy(modstr, str, strsize);
modstr[strsize-1] = '\0';
} /* modTimeToStr */


static int cmd_getlastmodtime(char *args)
{
PHYSFS_sint64 rc = PHYSFS_getLastModTime(args);
if (rc == -1)
printf("Failed to determine. Reason: [%s].\n", PHYSFS_getLastError());
else
{
char modstr[64];
modTimeToStr(rc, modstr, sizeof (modstr));
printf("Last modified: %s (%ld).\n", modstr, (long) rc);
} /* else */

return(1);
} /* cmd_getLastModTime */


/* must have spaces trimmed prior to this call. */
static int count_args(const char *str)
{
Expand Down Expand Up @@ -619,9 +646,11 @@ static const command_info commands[] =
{ "filelength", cmd_filelength, 1, "<fileToCheck>" },
{ "append", cmd_append, 1, "<fileToAppend>" },
{ "write", cmd_write, 1, "<fileToCreateOrTrash>" },
{ "getlastmodtime", cmd_getlastmodtime, 1, "<fileToExamine>" },
{ NULL, NULL, -1, NULL }
};


static void output_usage(const char *intro, const command_info *cmdinfo)
{
if (cmdinfo->argcount == 0)
Expand Down

0 comments on commit 9bcd3c1

Please sign in to comment.