From 2dcf1741fe1647e1bf3d60369c5e302696394d4e Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Mon, 16 Jul 2001 17:37:50 +0000 Subject: [PATCH] Added more API calls, always uses a history file, now. --- test/test_physfs.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/test/test_physfs.c b/test/test_physfs.c index d7b20fbf..5e02ec0e 100644 --- a/test/test_physfs.c +++ b/test/test_physfs.c @@ -260,6 +260,64 @@ static int cmd_setsaneconfig(char *args) } /* cmd_setsaneconfig */ +static int cmd_mkdir(char *args) +{ + if (PHYSFS_mkdir(args)) + printf("Successful.\n"); + else + printf("Failure. reason: %s.\n", PHYSFS_getLastError()); + + return(1); +} /* cmd_mkdir */ + + +static int cmd_delete(char *args) +{ + if (PHYSFS_delete(args)) + printf("Successful.\n"); + else + printf("Failure. reason: %s.\n", PHYSFS_getLastError()); + + return(1); +} /* cmd_delete */ + + +static int cmd_getrealdir(char *args) +{ + const char *rc = PHYSFS_getRealDir(args); + if (rc) + printf("Found at [%s].\n", rc); + else + printf("Not found.\n"); + + return(1); +} /* cmd_getrealdir */ + + +static int cmd_exists(char *args) +{ + int rc = PHYSFS_exists(args); + printf("File %sexists.\n", rc ? "" : "does not "); + return(1); +} /* cmd_exists */ + + +static int cmd_isdir(char *args) +{ + int rc = PHYSFS_isDirectory(args); + printf("File %s a directory.\n", rc ? "is" : "is NOT"); + return(1); +} /* cmd_isdir */ + + +static int cmd_issymlink(char *args) +{ + int rc = PHYSFS_isSymbolicLink(args); + printf("File %s a symlink.\n", rc ? "is" : "is NOT"); + return(1); +} /* cmd_issymlink */ + + /* must have spaces trimmed prior to this call. */ static int count_args(const char *str) { @@ -309,6 +367,12 @@ static const command_info commands[] = { "setwritedir", cmd_setwritedir, 1, "" }, { "permitsymlinks", cmd_permitsyms, 1, "<1or0>" }, { "setsaneconfig", cmd_setsaneconfig, 4, " " }, + { "mkdir", cmd_mkdir, 1, "" }, + { "delete", cmd_delete, 1, "" }, + { "getrealdir", cmd_getrealdir, 1, "" }, + { "exists", cmd_exists, 1, "" }, + { "isdir", cmd_isdir, 1, "" }, + { "issymlink", cmd_issymlink, 1, "" }, { NULL, NULL, -1, NULL } }; @@ -424,9 +488,15 @@ static int process_command(char *complete_cmd) static void open_history_file(void) { +#if 0 const char *envr = getenv("TESTPHYSFS_HISTORY"); if (!envr) return; +#else + char envr[256]; + strcpy(envr, PHYSFS_getUserDir()); + strcat(envr, ".testphys_history"); +#endif if (access(envr, F_OK) == 0) {