paragui-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[paragui-cvs] CVS: paragui/src/physfs/platform beos.cpp,1.1,1.2 posix.c,


From: Alexander Pipelka <address@hidden>
Subject: [paragui-cvs] CVS: paragui/src/physfs/platform beos.cpp,1.1,1.2 posix.c,1.1,1.2 Makefile.am,1.2,1.3 macclassic.c,1.1,1.2 skeleton.c,1.1,1.2 unix.c,1.2,1.3 win32.c,1.2,1.3
Date: Wed, 26 Jun 2002 04:30:15 -0400

Update of /cvsroot/paragui/paragui/src/physfs/platform
In directory subversions:/tmp/cvs-serv6214/src/physfs/platform

Modified Files:
        Makefile.am macclassic.c skeleton.c unix.c win32.c 
Added Files:
        beos.cpp posix.c 
Log Message:
updated physfs





Index: Makefile.am
===================================================================
RCS file: /cvsroot/paragui/paragui/src/physfs/platform/Makefile.am,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** Makefile.am 27 Apr 2002 16:06:26 -0000      1.2
--- Makefile.am 26 Jun 2002 08:30:11 -0000      1.3
***************
*** 1,10 ****
  EXTRA_DIST = \
!       beos.c \
!       darwin.c \
!       freebsd.c \
!       irix.c \
!       macclassic.c \
!       skeleton.c \
!       solaris.c \
        unix.c \
!       win32.c
--- 1,21 ----
+ noinst_LTLIBRARIES = libplatform.la
+ 
+ if BUILD_BEOS_CPP
+ libplatform_la_SOURCES = \
+       posix.c \
+       beos.cpp
+ else
+ libplatform_la_SOURCES = \
+       posix.c \
+       unix.c
+ endif
+ 
  EXTRA_DIST = \
!       posix.c \
        unix.c \
!       skeleton.c \
!       win32.c \
!       macclassic.c \
!       beos.cpp
! 
! INCLUDES = -I$(top_srcdir)

Index: macclassic.c
===================================================================
RCS file: /cvsroot/paragui/paragui/src/physfs/platform/macclassic.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** macclassic.c        27 Apr 2002 16:06:26 -0000      1.1
--- macclassic.c        26 Jun 2002 08:30:11 -0000      1.2
***************
*** 7,10 ****
--- 7,14 ----
   */
  
+ #if HAVE_CONFIG_H
+ #  include <config.h>
+ #endif
+ 
  #include <stdlib.h>
  #include <string.h>
***************
*** 801,804 ****
--- 805,834 ----
      /* no mutexes on MacOS Classic. */
  } /* __PHYSFS_platformReleaseMutex */
+ 
+ 
+ PHYSFS_sint64 __PHYSFS_platformGetLastModTime(const char *fname)
+ {
+     FSSpec spec;
+     CInfoPBRec infoPB;
+     UInt32 modDate;
+ 
+     BAIL_IF_MACRO(fnameToFSSpec(fname, &spec) != noErr, ERR_OS_ERROR, -1);
+ 
+     memset(&infoPB, '\0', sizeof (CInfoPBRec));
+     infoPB.dirInfo.ioNamePtr = spec.name;
+     infoPB.dirInfo.ioVRefNum = spec.vRefNum;
+     infoPB.dirInfo.ioDrDirID = spec.parID;
+     infoPB.dirInfo.ioFDirIndex = 0;
+     BAIL_IF_MACRO(PBGetCatInfoSync(&infoPB) != noErr, ERR_OS_ERROR, -1);
+ 
+     modDate = ((infoPB.dirInfo.ioFlAttrib & kioFlAttribDirMask) != 0) ?
+                    infoPB.dirInfo.ioDrMdDat : infoPB.hFileInfo.ioFlMdDat;
+ 
+     /* epoch is different on MacOS. They use Jan 1, 1904, apparently. */
+     /*  subtract seconds between those epochs, counting leap years.   */
+     modDate -= 2082844800;
+ 
+     return((PHYSFS_sint64) modDate);
+ } /* __PHYSFS_platformGetLastModTime */
  
  /* end of macclassic.c ... */

Index: skeleton.c
===================================================================
RCS file: /cvsroot/paragui/paragui/src/physfs/platform/skeleton.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** skeleton.c  27 Apr 2002 16:06:26 -0000      1.1
--- skeleton.c  26 Jun 2002 08:30:11 -0000      1.2
***************
*** 7,10 ****
--- 7,14 ----
   */
  
+ #if HAVE_CONFIG_H
+ #  include <config.h>
+ #endif
+ 
  #define __PHYSICSFS_INTERNAL__
  #include "physfs_internal.h"
***************
*** 217,220 ****
--- 221,230 ----
      /* not implemented, but can't call __PHYSFS_setError! */
  } /* __PHYSFS_platformReleaseMutex */
+ 
+ 
+ PHYSFS_sint64 __PHYSFS_platformGetLastModTime(const char *fname)
+ {
+     BAIL_MACRO(ERR_NOT_IMPLEMENTED, -1);
+ } /* __PHYSFS_platformGetLastModTime */
  
  /* end of skeleton.c ... */

Index: unix.c
===================================================================
RCS file: /cvsroot/paragui/paragui/src/physfs/platform/unix.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** unix.c      27 Apr 2002 16:06:26 -0000      1.2
--- unix.c      26 Jun 2002 08:30:11 -0000      1.3
***************
*** 7,10 ****
--- 7,16 ----
   */
  
+ #if HAVE_CONFIG_H
+ #  include <config.h>
+ #endif
+ 
+ #if (!defined __BEOS__) /* BeOS uses beos.cpp and posix.c ... */
+ 
  #if ((defined __APPLE__) && (defined __MACH__))
  #  if (!defined __DARWIN__)
***************
*** 13,37 ****
  #endif
  
- #if (defined __STRICT_ANSI__)
- #define __PHYSFS_DOING_STRICT_ANSI__
- #endif
- 
- /*
-  * We cheat a little: I want the symlink version of stat() (lstat), and
-  *  GCC/Linux will not declare it if compiled with the -ansi flag.
-  *  If you are really lacking symlink support on your platform,
-  *  you should #define __PHYSFS_NO_SYMLINKS__ before compiling this
-  *  file. That will open a security hole, though, if you really DO have
-  *  symlinks on your platform; it renders PHYSFS_permitSymbolicLinks(0)
-  *  useless, since every symlink will be reported as a regular file/dir.
-  */
- #if (defined __PHYSFS_DOING_STRICT_ANSI__)
- #undef __STRICT_ANSI__
- #endif
  #include <stdio.h>
- #if (defined __PHYSFS_DOING_STRICT_ANSI__)
- #define __STRICT_ANSI__
- #endif
- 
  #include <stdlib.h>
  #include <string.h>
--- 19,23 ----
***************
*** 97,101 ****
          else if ( strcmp( mntbufp[ii].f_fstypename, "cd9660") == 0 )
              add_it = 1;
!         /* !!! other mount types? */
  
          if (add_it)
--- 83,88 ----
          else if ( strcmp( mntbufp[ii].f_fstypename, "cd9660") == 0 )
              add_it = 1;
! 
!         /* add other mount types here */
  
          if (add_it)
***************
*** 116,121 ****
      }
  
-     free( mntbufp );
- 
      retval[cd_count - 1] = NULL;
      return(retval);
--- 103,106 ----
***************
*** 144,148 ****
          if (strcmp(ent->mnt_type, "iso9660") == 0)
              add_it = 1;
!         /* !!! other mount types? */
  
          if (add_it)
--- 129,134 ----
          if (strcmp(ent->mnt_type, "iso9660") == 0)
              add_it = 1;
! 
!         /* add other mount types here */
  
          if (add_it)
***************
*** 171,293 ****
  
  
! static char *copyEnvironmentVariable(const char *varname)
! {
!     const char *envr = getenv(varname);
!     char *retval = NULL;
  
-     if (envr != NULL)
-     {
-         retval = malloc(strlen(envr) + 1);
-         if (retval != NULL)
-             strcpy(retval, envr);
-     } /* if */
  
!     return(retval);
! } /* copyEnvironmentVariable */
! 
! 
! /* !!! this is ugly. */
! char *__PHYSFS_platformCalcBaseDir(const char *argv0)
  {
!     /* If there isn't a path on argv0, then look through the $PATH for it. */
! 
!     char *retval = NULL;
!     char *envr;
!     char *start;
      char *ptr;
-     char *exe;
  
!     if (strchr(argv0, '/') != NULL)   /* default behaviour can handle this. */
!         return(NULL);
! 
!     envr = copyEnvironmentVariable("PATH");
!     BAIL_IF_MACRO(!envr, NULL, NULL);
  
-     start = envr;
      do
      {
!         ptr = strchr(start, ':');
          if (ptr)
              *ptr = '\0';
  
!         exe = (char *) malloc(strlen(start) + strlen(argv0) + 2);
!         if (!exe)
          {
!             free(envr);
!             BAIL_IF_MACRO(1, ERR_OUT_OF_MEMORY, NULL);
          } /* if */
          strcpy(exe, start);
          if (exe[strlen(exe) - 1] != '/')
              strcat(exe, "/");
!         strcat(exe, argv0);
!         if (access(exe, X_OK) != 0)
!             free(exe);
!         else
          {
!             retval = exe;
!             strcpy(retval, start);  /* i'm lazy. piss off. */
!             break;
!         } /* else */
  
!         start = ptr + 1;
      } while (ptr != NULL);
  
!     free(envr);
!     return(retval);
! } /* __PHYSFS_platformCalcBaseDir */
! 
! 
! static char *getUserNameByUID(void)
! {
!     uid_t uid = getuid();
!     struct passwd *pw;
!     char *retval = NULL;
  
!     pw = getpwuid(uid);
!     if ((pw != NULL) && (pw->pw_name != NULL))
!     {
!         retval = malloc(strlen(pw->pw_name) + 1);
!         if (retval != NULL)
!             strcpy(retval, pw->pw_name);
!     } /* if */
!     
!     return(retval);
! } /* getUserNameByUID */
  
  
! static char *getUserDirByUID(void)
  {
!     uid_t uid = getuid();
!     struct passwd *pw;
!     char *retval = NULL;
! 
!     pw = getpwuid(uid);
!     if ((pw != NULL) && (pw->pw_dir != NULL))
!     {
!         retval = malloc(strlen(pw->pw_dir) + 1);
!         if (retval != NULL)
!             strcpy(retval, pw->pw_dir);
!     } /* if */
!     
!     return(retval);
! } /* getUserDirByUID */
! 
  
! char *__PHYSFS_platformGetUserName(void)
! {
!     char *retval = getUserNameByUID();
!     if (retval == NULL)
!         retval = copyEnvironmentVariable("USER");
!     return(retval);
! } /* __PHYSFS_platformGetUserName */
  
  
! char *__PHYSFS_platformGetUserDir(void)
! {
!     char *retval = copyEnvironmentVariable("HOME");
!     if (retval == NULL)
!         retval = getUserDirByUID();
      return(retval);
! } /* __PHYSFS_platformGetUserDir */
  
  
--- 157,243 ----
  
  
! /* this is in posix.c ... */
! extern char *__PHYSFS_platformCopyEnvironmentVariable(const char *varname);
  
  
! /*
!  * See where program (bin) resides in the $PATH specified by (envr).
!  *  returns a copy of the first element in envr that contains it, or NULL
!  *  if it doesn't exist or there were other problems. PHYSFS_SetError() is
!  *  called if we have a problem.
!  *
!  * (envr) will be scribbled over, and you are expected to free() the
!  *  return value when you're done with it.
!  */
! static char *findBinaryInPath(const char *bin, char *envr)
  {
!     size_t alloc_size = 0;
!     char *exe = NULL;
!     char *start = envr;
      char *ptr;
  
!     BAIL_IF_MACRO(bin == NULL, ERR_INVALID_ARGUMENT, NULL);
!     BAIL_IF_MACRO(envr == NULL, ERR_INVALID_ARGUMENT, NULL);
  
      do
      {
!         size_t size;
!         ptr = strchr(start, ':');  /* find next $PATH separator. */
          if (ptr)
              *ptr = '\0';
  
!         size = strlen(start) + strlen(bin) + 2;
!         if (size > alloc_size)
          {
!             char *x = (char *) realloc(exe, size);
!             if (x == NULL)
!             {
!                 if (exe != NULL)
!                     free(exe);
!                 BAIL_MACRO(ERR_OUT_OF_MEMORY, NULL);
!             } /* if */
! 
!             alloc_size = size;
!             exe = x;
          } /* if */
+ 
+         /* build full binary path... */
          strcpy(exe, start);
          if (exe[strlen(exe) - 1] != '/')
              strcat(exe, "/");
!         strcat(exe, bin);
! 
!         if (access(exe, X_OK) == 0)  /* Exists as executable? We're done. */
          {
!             strcpy(exe, start);  /* i'm lazy. piss off. */
!             return(exe);
!         } /* if */
  
!         start = ptr + 1;  /* start points to beginning of next element. */
      } while (ptr != NULL);
  
!     if (exe != NULL)
!         free(exe);
  
!     return(NULL);  /* doesn't exist in path. */
! } /* findBinaryInPath */
  
  
! char *__PHYSFS_platformCalcBaseDir(const char *argv0)
  {
!     /* If there isn't a path on argv0, then look through the $PATH for it. */
  
!     char *retval;
!     char *envr;
  
+     if (strchr(argv0, '/') != NULL)   /* default behaviour can handle this. */
+         return(NULL);
  
!     envr = __PHYSFS_platformCopyEnvironmentVariable("PATH");
!     BAIL_IF_MACRO(!envr, NULL, NULL);
!     retval = findBinaryInPath(argv0, envr);
!     free(envr);
      return(retval);
! } /* __PHYSFS_platformCalcBaseDir */
  
  
***************
*** 298,392 ****
  
  
- /* -ansi and -pedantic flags prevent use of strcasecmp() on Linux. */
- int __PHYSFS_platformStricmp(const char *x, const char *y)
- {
-     int ux, uy;
- 
-     do
-     {
-         ux = toupper((int) *x);
-         uy = toupper((int) *y);
-         if (ux > uy)
-             return(1);
-         else if (ux < uy)
-             return(-1);
-         x++;
-         y++;
-     } while ((ux) && (uy));
- 
-     return(0);
- } /* __PHYSFS_platformStricmp */
- 
- 
- int __PHYSFS_platformExists(const char *fname)
- {
-     struct stat statbuf;
-     return(stat(fname, &statbuf) == 0);
- } /* __PHYSFS_platformExists */
- 
- 
- int __PHYSFS_platformIsSymLink(const char *fname)
- {
- #if (defined __PHYSFS_NO_SYMLINKS__)
-     return(0);
- #else
- 
-     struct stat statbuf;
-     int retval = 0;
- 
-     if (lstat(fname, &statbuf) == 0)
-     {
-         if (S_ISLNK(statbuf.st_mode))
-             retval = 1;
-     } /* if */
-     
-     return(retval);
- 
- #endif
- } /* __PHYSFS_platformIsSymlink */
- 
- 
- int __PHYSFS_platformIsDirectory(const char *fname)
- {
-     struct stat statbuf;
-     int retval = 0;
- 
-     if (stat(fname, &statbuf) == 0)
-     {
-         if (S_ISDIR(statbuf.st_mode))
-             retval = 1;
-     } /* if */
-     
-     return(retval);
- } /* __PHYSFS_platformIsDirectory */
- 
- 
- char *__PHYSFS_platformCvtToDependent(const char *prepend,
-                                       const char *dirName,
-                                       const char *append)
- {
-     int len = ((prepend) ? strlen(prepend) : 0) +
-               ((append) ? strlen(append) : 0) +
-               strlen(dirName) + 1;
-     char *retval = malloc(len);
- 
-     BAIL_IF_MACRO(retval == NULL, ERR_OUT_OF_MEMORY, NULL);
- 
-     /* platform-independent notation is Unix-style already.  :)  */
- 
-     if (prepend)
-         strcpy(retval, prepend);
-     else
-         retval[0] = '\0';
- 
-     strcat(retval, dirName);
- 
-     if (append)
-         strcat(retval, append);
- 
-     return(retval);
- } /* __PHYSFS_platformCvtToDependent */
- 
- 
  /* Much like my college days, try to sleep for 10 milliseconds at a time... */
  void __PHYSFS_platformTimeslice(void)
--- 248,251 ----
***************
*** 396,530 ****
  
  
- LinkedStringList *__PHYSFS_platformEnumerateFiles(const char *dirname,
-                                                   int omitSymLinks)
- {
-     LinkedStringList *retval = NULL;
-     LinkedStringList *l = NULL;
-     LinkedStringList *prev = NULL;
-     DIR *dir;
-     struct dirent *ent;
-     int bufsize = 0;
-     char *buf = NULL;
-     int dlen = 0;
- 
-     if (omitSymLinks)
-     {
-         dlen = strlen(dirname);
-         bufsize = dlen + 256;
-         buf = malloc(bufsize);
-         BAIL_IF_MACRO(buf == NULL, ERR_OUT_OF_MEMORY, NULL);
-         strcpy(buf, dirname);
-         if (buf[dlen - 1] != '/')
-         {
-             buf[dlen++] = '/';
-             buf[dlen] = '\0';
-         } /* if */
-     } /* if */
- 
-     errno = 0;
-     dir = opendir(dirname);
-     if (dir == NULL)
-     {
-         if (buf != NULL)
-             free(buf);
-         BAIL_IF_MACRO(1, strerror(errno), NULL);
-     } /* if */
- 
-     while (1)
-     {
-         ent = readdir(dir);
-         if (ent == NULL)   /* we're done. */
-             break;
- 
-         if (strcmp(ent->d_name, ".") == 0)
-             continue;
- 
-         if (strcmp(ent->d_name, "..") == 0)
-             continue;
- 
-         if (omitSymLinks)
-         {
-             char *p;
-             int len = strlen(ent->d_name) + dlen + 1;
-             if (len > bufsize)
-             {
-                 p = realloc(buf, len);
-                 if (p == NULL)
-                     continue;
-                 buf = p;
-                 bufsize = len;
-             } /* if */
- 
-             strcpy(buf + dlen, ent->d_name);
-             if (__PHYSFS_platformIsSymLink(buf))
-                 continue;
-         } /* if */
- 
-         l = (LinkedStringList *) malloc(sizeof (LinkedStringList));
-         if (l == NULL)
-             break;
- 
-         l->str = (char *) malloc(strlen(ent->d_name) + 1);
-         if (l->str == NULL)
-         {
-             free(l);
-             break;
-         } /* if */
- 
-         strcpy(l->str, ent->d_name);
- 
-         if (retval == NULL)
-             retval = l;
-         else
-             prev->next = l;
- 
-         prev = l;
-         l->next = NULL;
-     } /* while */
- 
-     if (buf != NULL)
-         free(buf);
- 
-     closedir(dir);
-     return(retval);
- } /* __PHYSFS_platformEnumerateFiles */
- 
- 
- char *__PHYSFS_platformCurrentDir(void)
- {
-     int allocSize = 0;
-     char *retval = NULL;
-     char *ptr;
- 
-     do
-     {
-         allocSize += 100;
-         ptr = (char *) realloc(retval, allocSize);
-         if (ptr == NULL)
-         {
-             if (retval != NULL)
-                 free(retval);
-             BAIL_MACRO(ERR_OUT_OF_MEMORY, NULL);
-         } /* if */
- 
-         retval = ptr;
-         ptr = getcwd(retval, allocSize);
-     } while (ptr == NULL && errno == ERANGE);
- 
-     if (ptr == NULL && errno)
-     {
-             /*
-              * getcwd() failed for some reason, for example current
-              * directory not existing.
-              */
-         if (retval != NULL)
-             free(retval);
-         BAIL_MACRO(ERR_NO_SUCH_FILE, NULL);
-     } /* if */
- 
-     return(retval);
- } /* __PHYSFS_platformCurrentDir */
- 
- 
  char *__PHYSFS_platformRealPath(const char *path)
  {
--- 255,258 ----
***************
*** 534,538 ****
      errno = 0;
      BAIL_IF_MACRO(!realpath(path, resolved_path), strerror(errno), NULL);
!     retval = malloc(strlen(resolved_path) + 1);
      BAIL_IF_MACRO(retval == NULL, ERR_OUT_OF_MEMORY, NULL);
      strcpy(retval, resolved_path);
--- 262,266 ----
      errno = 0;
      BAIL_IF_MACRO(!realpath(path, resolved_path), strerror(errno), NULL);
!     retval = (char *) malloc(strlen(resolved_path) + 1);
      BAIL_IF_MACRO(retval == NULL, ERR_OUT_OF_MEMORY, NULL);
      strcpy(retval, resolved_path);
***************
*** 541,674 ****
  
  
- int __PHYSFS_platformMkDir(const char *path)
- {
-     int rc;
-     errno = 0;
-     rc = mkdir(path, S_IRWXU);
-     BAIL_IF_MACRO(rc == -1, strerror(errno), 0);
-     return(1);
- } /* __PHYSFS_platformMkDir */
- 
- 
- static void *doOpen(const char *filename, const char *mode)
- {
-     FILE *retval;
-     errno = 0;
- 
-     retval = fopen(filename, mode);
-     if (retval == NULL)
-         __PHYSFS_setError(strerror(errno));
- 
-     return((void *) retval);
- } /* doOpen */
- 
- 
- void *__PHYSFS_platformOpenRead(const char *filename)
- {
-     return(doOpen(filename, "rb"));
- } /* __PHYSFS_platformOpenRead */
- 
- 
- void *__PHYSFS_platformOpenWrite(const char *filename)
- {
-     return(doOpen(filename, "wb"));
- } /* __PHYSFS_platformOpenWrite */
- 
- 
- void *__PHYSFS_platformOpenAppend(const char *filename)
- {
-     return(doOpen(filename, "wb+"));
- } /* __PHYSFS_platformOpenAppend */
- 
- 
- PHYSFS_sint64 __PHYSFS_platformRead(void *opaque, void *buffer,
-                                     PHYSFS_uint32 size, PHYSFS_uint32 count)
- {
-     FILE *io = (FILE *) opaque;
-     int rc = fread(buffer, size, count, io);
-     if (rc < count)
-     {
-         int err = errno;
-         BAIL_IF_MACRO(ferror(io), strerror(err), rc);
-         BAIL_MACRO(ERR_PAST_EOF, rc);
-     } /* if */
- 
-     return(rc);
- } /* __PHYSFS_platformRead */
- 
- 
- PHYSFS_sint64 __PHYSFS_platformWrite(void *opaque, const void *buffer,
-                                      PHYSFS_uint32 size, PHYSFS_uint32 count)
- {
-     FILE *io = (FILE *) opaque;
-     int rc = fwrite((void *) buffer, size, count, io);
-     if (rc < count)
-         __PHYSFS_setError(strerror(errno));
- 
-     return(rc);
- } /* __PHYSFS_platformWrite */
- 
- 
- int __PHYSFS_platformSeek(void *opaque, PHYSFS_uint64 pos)
- {
-     FILE *io = (FILE *) opaque;
- 
-     /* !!! FIXME: Use llseek where available. */
-     errno = 0;
-     BAIL_IF_MACRO(fseek(io, pos, SEEK_SET) != 0, strerror(errno), 0);
- 
-     return(1);
- } /* __PHYSFS_platformSeek */
- 
- 
- PHYSFS_sint64 __PHYSFS_platformTell(void *opaque)
- {
-     FILE *io = (FILE *) opaque;
-     PHYSFS_sint64 retval = ftell(io);
-     BAIL_IF_MACRO(retval == -1, strerror(errno), -1);
-     return(retval);
- } /* __PHYSFS_platformTell */
- 
- 
- PHYSFS_sint64 __PHYSFS_platformFileLength(void *opaque)
- {
-     FILE *io = (FILE *) opaque;
-     struct stat statbuf;
-     errno = 0;
-     BAIL_IF_MACRO(fstat(fileno(io), &statbuf) == -1, strerror(errno), -1);
-     return((PHYSFS_sint64) statbuf.st_size);
- } /* __PHYSFS_platformFileLength */
- 
- 
- int __PHYSFS_platformEOF(void *opaque)
- {
-     return(feof((FILE *) opaque));
- } /* __PHYSFS_platformEOF */
- 
- 
- int __PHYSFS_platformFlush(void *opaque)
- {
-     errno = 0;
-     BAIL_IF_MACRO(fflush((FILE *) opaque) == EOF, strerror(errno), 0);
-     return(1);
- } /* __PHYSFS_platformFlush */
- 
- 
- int __PHYSFS_platformClose(void *opaque)
- {
-     errno = 0;
-     BAIL_IF_MACRO(fclose((FILE *) opaque) == EOF, strerror(errno), 0);
-     return(1);
- } /* __PHYSFS_platformClose */
- 
- 
- int __PHYSFS_platformDelete(const char *path)
- {
-     errno = 0;
-     BAIL_IF_MACRO(remove(path) == -1, strerror(errno), 0);
-     return(1);
- } /* __PHYSFS_platformDelete */
- 
- 
  void *__PHYSFS_platformCreateMutex(void)
  {
--- 269,272 ----
***************
*** 704,707 ****
--- 302,307 ----
      pthread_mutex_unlock((pthread_mutex_t *) mutex);
  } /* __PHYSFS_platformReleaseMutex */
+ 
+ #endif /* !defined __BEOS__ */
  
  /* end of unix.c ... */

Index: win32.c
===================================================================
RCS file: /cvsroot/paragui/paragui/src/physfs/platform/win32.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** win32.c     27 Apr 2002 16:06:26 -0000      1.2
--- win32.c     26 Jun 2002 08:30:11 -0000      1.3
***************
*** 7,15 ****
   */
  
  #include <windows.h>
- #include <userenv.h>
  #include <stdio.h>
  #include <stdlib.h>
  #include <ctype.h>
  
  #define __PHYSICSFS_INTERNAL__
--- 7,20 ----
   */
  
+ #if HAVE_CONFIG_H
+ #  include <config.h>
+ #endif
+ 
  #include <windows.h>
  #include <stdio.h>
  #include <stdlib.h>
  #include <ctype.h>
+ #include <time.h>
+ #include <assert.h>
  
  #define __PHYSICSFS_INTERNAL__
***************
*** 21,33 ****
  const char *__PHYSFS_platformDirSeparator = "\\";
  
! static HANDLE ProcessHandle = NULL;     /* Current process handle */
! static HANDLE AccessTokenHandle = NULL; /* Security handle to process */
! static DWORD ProcessID;                 /* ID assigned to current process */
! static int runningNT;                   /* TRUE if NT derived OS */
  static OSVERSIONINFO OSVersionInfo;     /* Information about the OS */
- 
- /* NT specific information */
  static char *ProfileDirectory = NULL;   /* User profile folder */
  
  static const char *win32strerror(void)
  {
--- 26,47 ----
  const char *__PHYSFS_platformDirSeparator = "\\";
  
! static int runningNT = 0;               /* TRUE if NT derived OS */
  static OSVERSIONINFO OSVersionInfo;     /* Information about the OS */
  static char *ProfileDirectory = NULL;   /* User profile folder */
  
+ /* Users without the platform SDK don't have this defined.  The original docs
+    for SetFilePointer() just said to compare with 0xFFFFFFF, so this should
+    work as desired */
+ #ifndef INVALID_SET_FILE_POINTER
+ #define INVALID_SET_FILE_POINTER 0xFFFFFFFF
+ #endif
+ 
+ /*
+  * Figure out what the last failing Win32 API call was, and
+  *  generate a human-readable string for the error message.
+  *
+  * The return value is a static buffer that is overwritten with
+  *  each call to this function.
+  */
  static const char *win32strerror(void)
  {
***************
*** 49,52 ****
--- 63,177 ----
  
  
+ /*
+  * Uninitialize any NT specific stuff done in doNTInit().
+  *
+  * Return zero if there was a catastrophic failure and non-zero otherwise.
+  */
+ static int doNTDeinit(void)
+ {
+     /* nothing NT-specific to deinit at this point. */
+     return 1;  /* It's all good */
+ } /* doNTDeinit */
+ 
+ 
+ typedef BOOL (STDMETHODCALLTYPE FAR * LPFNGETUSERPROFILEDIR) (
+       HANDLE hToken,
+       LPTSTR lpProfileDir,
+       LPDWORD lpcchSize);
+    
+ /*
+  * Initialize any NT specific stuff.  This includes any OS based on NT.
+  *
+  * Return zero if there was a catastrophic failure and non-zero otherwise.
+  */
+ static int doNTInit(void)
+ {
+     DWORD pathsize = 0;
+     char dummy[1];
+     BOOL rc = 0;
+     HANDLE ProcessHandle = NULL;     /* Current process handle */
+     HANDLE AccessTokenHandle = NULL; /* Security handle to process */
+     LPFNGETUSERPROFILEDIR GetUserProfileDirectory = NULL;
+     HMODULE lib = NULL;
+     const char *err = NULL;
+ 
+     /* Hooray for spaghetti code! */
+ 
+     lib = LoadLibrary("userenv.dll");
+     if (!lib)
+         goto ntinit_failed;
+ 
+     /* !!! FIXME: Handle Unicode? */
+     GetUserProfileDirectory = (LPFNGETUSERPROFILEDIR)
+                               GetProcAddress(lib, "GetUserProfileDirectoryA");
+     if (!GetUserProfileDirectory)
+         goto ntinit_failed;
+ 
+     /* Create a process handle associated with the current process ID */
+     ProcessHandle = GetCurrentProcess();
+ 
+     /* Create a process access token handle */
+     if(!OpenProcessToken(ProcessHandle, TOKEN_QUERY, &AccessTokenHandle))
+         goto ntinit_failed; /* we need that token to get the profile dir. */
+ 
+     /* Should fail.  Will write the size of the profile path in pathsize */
+     /* Second parameter can't be NULL or the function fails. */
+     rc = GetUserProfileDirectory(AccessTokenHandle, dummy, &pathsize);
+     assert(!rc);  /* success?! */
+ 
+     /* Allocate memory for the profile directory */
+     ProfileDirectory = (char *) malloc(pathsize);
+     if (ProfileDirectory == NULL)
+     {
+         err = ERR_OUT_OF_MEMORY;
+         goto ntinit_failed;
+     } /* if */
+ 
+     /* Try to get the profile directory */
+     if(!GetUserProfileDirectory(AccessTokenHandle, ProfileDirectory, 
&pathsize))
+         goto ntinit_failed;
+ 
+     goto ntinit_succeeded;  /* We made it: hit the showers. */
+ 
+ ntinit_failed:
+     if (err == NULL) /* set an error string if we haven't yet. */
+         __PHYSFS_setError(win32strerror());
+ 
+     if (ProfileDirectory != NULL)
+     {
+         free(ProfileDirectory);
+         ProfileDirectory = NULL;
+     } /* if */
+ 
+     /* drop through and clean up the rest of the stuff... */
+ 
+ ntinit_succeeded:
+     if (lib != NULL)
+         FreeLibrary(lib);
+ 
+     if (AccessTokenHandle != NULL)
+         CloseHandle(AccessTokenHandle);
+ 
+     return ((err == NULL) ? 1 : 0);
+ } /* doNTInit */
+ 
+ static BOOL MediaInDrive(const char *DriveLetter)
+ {
+     UINT OldErrorMode;
+     DWORD DummyValue;
+     BOOL ReturnValue;
+ 
+     /* Prevent windows warning message to appear when checking media size */
+     OldErrorMode = SetErrorMode(SEM_FAILCRITICALERRORS);
+     
+     /* If this function succeeds, there's media in the drive */
+     ReturnValue = GetDiskFreeSpace(DriveLetter, &DummyValue, &DummyValue, 
&DummyValue, &DummyValue);
+ 
+     /* Revert back to old windows error handler */
+     SetErrorMode(OldErrorMode);
+ 
+     return ReturnValue;
+ } /* MediaInDrive */
+ 
  char **__PHYSFS_platformDetectAvailableCDs(void)
  {
***************
*** 57,65 ****
      for (drive_str[0] = 'A'; drive_str[0] <= 'Z'; drive_str[0]++)
      {
!         if (GetDriveType(drive_str) == DRIVE_CDROM)
          {
- 
-             /* !!! FIXME: Make sure there's really a disc in the drive? */
- 
              char **tmp = realloc(retval, sizeof (char *) * cd_count + 1);
              if (tmp)
--- 182,187 ----
      for (drive_str[0] = 'A'; drive_str[0] <= 'Z'; drive_str[0]++)
      {
!         if (GetDriveType(drive_str) == DRIVE_CDROM && MediaInDrive(drive_str))
          {
              char **tmp = realloc(retval, sizeof (char *) * cd_count + 1);
              if (tmp)
***************
*** 84,89 ****
  {
      char *filepart = NULL;
!     char *retval = (char *) malloc(sizeof (TCHAR) * (MAX_PATH + 1));
!     DWORD buflen = GetModuleFileName(NULL, retval, MAX_PATH + 1);
      retval[buflen] = '\0';  /* does API always null-terminate the string? */
  
--- 206,222 ----
  {
      char *filepart = NULL;
!     char *retval;
!       DWORD buflen;
!               
!       retval = (char *) malloc(sizeof (TCHAR) * (MAX_PATH + 1));
!       BAIL_IF_MACRO(retval == NULL, ERR_OUT_OF_MEMORY, NULL);
!     buflen = GetModuleFileName(NULL, retval, MAX_PATH + 1);
!       if (buflen == 0)
!     {
!         const char *err = win32strerror();
!         free(retval);
!         BAIL_MACRO(err, NULL);
!     } /* if */
! 
      retval[buflen] = '\0';  /* does API always null-terminate the string? */
  
***************
*** 97,103 ****
  
              /* free up the bytes we didn't actually use. */            
!             retval = (char *) realloc(retval, strlen(retval) + 1);
!             if (retval != NULL)
!                 return(retval);
          } /* if */
      } /* if */
--- 230,238 ----
  
              /* free up the bytes we didn't actually use. */            
!             ptr = (char *) realloc(retval, strlen(retval) + 1);
!             if (ptr != NULL)
!                           retval = ptr;
! 
!             return(retval);
          } /* if */
      } /* if */
***************
*** 133,136 ****
--- 268,272 ----
          if (GetUserName(retval, &bufsize) == 0)  /* ?! */
          {
+             __PHYSFS_setError(win32strerror());
              free(retval);
              retval = NULL;
***************
*** 144,159 ****
  char *__PHYSFS_platformGetUserDir(void)
  {
!     char *userdir = NULL;
! 
!     if (runningNT)
!     {
!         userdir = ProfileDirectory;
!     }
!     else
!     {
!         /*!!!TODO - Need to return something for Win9x/ME */
!     }
! 
!     return userdir;
  } /* __PHYSFS_platformGetUserDir */
  
--- 280,287 ----
  char *__PHYSFS_platformGetUserDir(void)
  {
!     char *retval = (char *) malloc(strlen(ProfileDirectory) + 1);
!     BAIL_IF_MACRO(retval == NULL, ERR_OUT_OF_MEMORY, NULL);
!     strcpy(retval, ProfileDirectory); /* calculated at init time. */
!       return retval;
  } /* __PHYSFS_platformGetUserDir */
  
***************
*** 252,260 ****
      HANDLE dir;
      WIN32_FIND_DATA ent;
  
!     dir = FindFirstFile(dirname, &ent);
      BAIL_IF_MACRO(dir == INVALID_HANDLE_VALUE, win32strerror(), NULL);
  
!     while (FindNextFile(dir, &ent) != 0)
      {
          if (strcmp(ent.cFileName, ".") == 0)
--- 380,407 ----
      HANDLE dir;
      WIN32_FIND_DATA ent;
+     char *SearchPath;
+     size_t len = strlen(dirname);
+ 
+     /* Allocate a new string for path, maybe '\\', "*", and NULL terminator */
+     SearchPath = (char *) _alloca(len + 3);
+     BAIL_IF_MACRO(SearchPath == NULL, ERR_OUT_OF_MEMORY, NULL);
  
!     /* Copy current dirname */
!     strcpy(SearchPath, dirname);
! 
!     /* if there's no '\\' at the end of the path, stick one in there. */
!     if (SearchPath[len - 1] != '\\')
!     {
!         SearchPath[len++] = '\\';
!         SearchPath[len] = '\0';
!     } /* if */
! 
!     /* Append the "*" to the end of the string */
!     strcat(SearchPath, "*");
! 
!     dir = FindFirstFile(SearchPath, &ent);
      BAIL_IF_MACRO(dir == INVALID_HANDLE_VALUE, win32strerror(), NULL);
  
!     do
      {
          if (strcmp(ent.cFileName, ".") == 0)
***************
*** 284,288 ****
          prev = l;
          l->next = NULL;
!     } /* while */
  
      FindClose(dir);
--- 431,435 ----
          prev = l;
          l->next = NULL;
!     } while (FindNextFile(dir, &ent) != 0);
  
      FindClose(dir);
***************
*** 436,474 ****
  } /* __PHYSFS_platformMkDir */
  
- /*
-  * Initialize any NT specific stuff.  This includes any OS based on NT.
-  *
-  * Return zero if there was a catastrophic failure and non-zero otherwise.
-  */
- static int doNTInit(void)
- {
-     DWORD pathsize = 0;
-     char TempProfileDirectory[1];
- 
-     /* Create a process access token handle */
-     if(!OpenProcessToken(ProcessHandle, TOKEN_QUERY, &AccessTokenHandle))
-     {
-         /* Access token is required by other win32 functions */
-         return 0;
-     }
- 
-     /* Should fail.  Will write the size of the profile path in pathsize*/
-     /*!!! Second parameter can't be NULL or the function fails??? */
-     if(!GetUserProfileDirectory(AccessTokenHandle, TempProfileDirectory, 
&pathsize))
-     {
-         /* Allocate memory for the profile directory */
-         ProfileDirectory = (char *)malloc(pathsize);
-         BAIL_IF_MACRO(ProfileDirectory == NULL, ERR_OUT_OF_MEMORY, 0);
-         /* Try to get the profile directory */
-         if(!GetUserProfileDirectory(AccessTokenHandle, ProfileDirectory, 
&pathsize))
-         {
-             free(ProfileDirectory);
-             return 0;
-         }
-     }
- 
-     /* Everything initialized okay */
-     return 1;
- }
  
  /* 
--- 583,586 ----
***************
*** 481,488 ****
      /* Get OS info */
      OSVersionInfo.dwOSVersionInfoSize = sizeof(OSVersionInfo);
!     if(!GetVersionEx(&OSVersionInfo))
!     {
!         return 0;
!     }
  
      /* Set to TRUE if we are runnign a WinNT based OS 4.0 or greater */
--- 593,597 ----
      /* Get OS info */
      OSVersionInfo.dwOSVersionInfoSize = sizeof(OSVersionInfo);
!     BAIL_IF_MACRO(!GetVersionEx(&OSVersionInfo), win32strerror(), 0);
  
      /* Set to TRUE if we are runnign a WinNT based OS 4.0 or greater */
***************
*** 495,556 ****
  int __PHYSFS_platformInit(void)
  {
!     if(!getOSInfo())
!     {
!         return 0;
!     }
! 
!     /* Get Windows ProcessID associated with the current process */
!     ProcessID = GetCurrentProcessId();
!     /* Create a process handle associated with the current process ID */
!     ProcessHandle = GetCurrentProcess();
! 
!     if(ProcessHandle == NULL)
!     {
!         /* Process handle is required by other win32 functions */
!         return 0;
!     }
  
      /* If running an NT system (NT/Win2k/XP, etc...) */
      if(runningNT)
      {
!         if(!doNTInit())
!         {
!             /* Error initializing NT stuff */
!             return 0;
!         }
!     }
! 
!     /* It's all good */
!     return 1;
! }
! 
! /*
!  * Uninitialize any NT specific stuff done in doNTInit().
!  *
!  * Return zero if there was a catastrophic failure and non-zero otherwise.
!  */
! static int doNTDeinit(void)
! {
!     if(CloseHandle(AccessTokenHandle) != S_OK)
      {
!         return 0;
!     }
! 
!     free(ProfileDirectory);
  
!     /* It's all good */
!     return 1;
  }
  
  int __PHYSFS_platformDeinit(void)
  {
!     if(!doNTDeinit())
!         return 0;
  
!     if(CloseHandle(ProcessHandle) != S_OK)
!         return 0;
  
!     /* It's all good */
!     return 1;
  }
  
--- 604,638 ----
  int __PHYSFS_platformInit(void)
  {
!     BAIL_IF_MACRO(!getOSInfo(), NULL, 0);
  
      /* If running an NT system (NT/Win2k/XP, etc...) */
      if(runningNT)
      {
!         BAIL_IF_MACRO(!doNTInit(), NULL, 0);
!     } /* if */
!     else
      {
!         /* Profile directory is the exe path on 95/98/ME systems. */
!       ProfileDirectory = getExePath(NULL);
!         BAIL_IF_MACRO(ProfileDirectory == NULL, win32strerror(), 0);
!     } /* else */
  
!     return 1;  /* It's all good */
  }
  
  int __PHYSFS_platformDeinit(void)
  {
!     if (runningNT)
!     {
!         BAIL_IF_MACRO(!doNTDeinit(), NULL, 0);
!     } /* if */
  
!     if (ProfileDirectory != NULL)
!     {
!         free(ProfileDirectory);
!         ProfileDirectory = NULL;
!     } /* if */
  
!     return 1; /* It's all good */
  }
  
***************
*** 564,571 ****
          OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
  
!     /* If CreateFile() failed */
!     if(FileHandle == INVALID_HANDLE_VALUE)
!         return NULL;
! 
      return (void *)FileHandle;
  }
--- 646,650 ----
          OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
  
!     BAIL_IF_MACRO(FileHandle == INVALID_HANDLE_VALUE, win32strerror(), NULL);
      return (void *)FileHandle;
  }
***************
*** 580,587 ****
          CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
  
!     /* If CreateFile() failed */
!     if(FileHandle == INVALID_HANDLE_VALUE)
!         return NULL;
! 
      return (void *)FileHandle;
  }
--- 659,663 ----
          CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
  
!     BAIL_IF_MACRO(FileHandle == INVALID_HANDLE_VALUE, win32strerror(), NULL);
      return (void *)FileHandle;
  }
***************
*** 594,605 ****
         who request read access to the file only. */
      FileHandle = CreateFile(filename, GENERIC_WRITE, FILE_SHARE_READ, NULL, 
!         TRUNCATE_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
! 
!     /* If CreateFile() failed */
!     if(FileHandle == INVALID_HANDLE_VALUE)
!         /* CreateFile might have failed because the file doesn't exist, so
!            we'll just create a new file for writing then */
!         return __PHYSFS_platformOpenWrite(filename);
  
      return (void *)FileHandle;
  }
--- 670,676 ----
         who request read access to the file only. */
      FileHandle = CreateFile(filename, GENERIC_WRITE, FILE_SHARE_READ, NULL, 
!         OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
  
+     BAIL_IF_MACRO(FileHandle == INVALID_HANDLE_VALUE, win32strerror(), NULL);
      return (void *)FileHandle;
  }
***************
*** 619,627 ****
      if(!ReadFile(FileHandle, buffer, count * size, &CountOfBytesRead, NULL))
      {
!         /* Set the error to GetLastError */
!         __PHYSFS_setError(win32strerror());
!         /* We errored out */
!         retval = -1;
!     }
      else
      {
--- 690,695 ----
      if(!ReadFile(FileHandle, buffer, count * size, &CountOfBytesRead, NULL))
      {
!         BAIL_MACRO(win32strerror(), -1);
!     } /* if */
      else
      {
***************
*** 629,633 ****
          /* !!! - What if not the right amount of bytes was read to make an 
object? */
          retval = CountOfBytesRead / size;
!     }
  
      return retval;
--- 697,701 ----
          /* !!! - What if not the right amount of bytes was read to make an 
object? */
          retval = CountOfBytesRead / size;
!     } /* else */
  
      return retval;
***************
*** 648,656 ****
      if(!WriteFile(FileHandle, buffer, count * size, &CountOfBytesWritten, 
NULL))
      {
!         /* Set the error to GetLastError */
!         __PHYSFS_setError(win32strerror());
!         /* We errored out */
!         retval = -1;
!     }
      else
      {
--- 716,721 ----
      if(!WriteFile(FileHandle, buffer, count * size, &CountOfBytesWritten, 
NULL))
      {
!         BAIL_MACRO(win32strerror(), -1);
!     } /* if */
      else
      {
***************
*** 658,662 ****
          /*!!! - What if not the right number of bytes was written? */
          retval = CountOfBytesWritten / size;
!     }
  
      return retval;
--- 723,727 ----
          /*!!! - What if not the right number of bytes was written? */
          retval = CountOfBytesWritten / size;
!     } /* else */
  
      return retval;
***************
*** 708,718 ****
          == INVALID_SET_FILE_POINTER) && (GetLastError() != NO_ERROR))
      {
-         /* Combine the high/low order to create the 64-bit position value */
-         retval = HighOrderPos;
-         retval = retval << 32;
-         retval |= LowOrderPos;
-     }
-     else
-     {
          /* Set the error to GetLastError */
          __PHYSFS_setError(win32strerror());
--- 773,776 ----
***************
*** 720,723 ****
--- 778,788 ----
          retval = 0;
      }
+     else
+     {
+         /* Combine the high/low order to create the 64-bit position value */
+         retval = HighOrderPos;
+         retval = retval << 32;
+         retval |= LowOrderPos;
+     }
  
      /*!!! Can't find a file pointer routine?!?!?!!?!?*/
***************
*** 734,753 ****
      /* Cast the generic handle to a Win32 handle */
      FileHandle = (HANDLE)handle;
!     
      if(((FileSizeLow = GetFileSize(FileHandle, &FileSizeHigh))
          == INVALID_SET_FILE_POINTER) && (GetLastError() != NO_ERROR))
      {
          /* Combine the high/low order to create the 64-bit position value */
          retval = FileSizeHigh;
          retval = retval << 32;
          retval |= FileSizeLow;
!     }
!     else
!     {
!         /* Set the error to GetLastError */
!         __PHYSFS_setError(win32strerror());
! 
!         retval = -1;
!     }
  
      return retval;
--- 799,816 ----
      /* Cast the generic handle to a Win32 handle */
      FileHandle = (HANDLE)handle;
! 
!     /* Get the file size.  Condition evaluates to TRUE if an error occured */
      if(((FileSizeLow = GetFileSize(FileHandle, &FileSizeHigh))
          == INVALID_SET_FILE_POINTER) && (GetLastError() != NO_ERROR))
      {
+         BAIL_MACRO(win32strerror(), -1);
+     } /* if */
+     else
+     {
          /* Combine the high/low order to create the 64-bit position value */
          retval = FileSizeHigh;
          retval = retval << 32;
          retval |= FileSizeLow;
!     } /* else */
  
      return retval;
***************
*** 766,771 ****
      if((FilePosition = __PHYSFS_platformTell(opaque)) != 0)
      {
!         /* Non-zero if EOF is equal to the file length - 1 */
!         retval = FilePosition == __PHYSFS_platformFileLength(opaque) - 1;
      }
  
--- 829,834 ----
      if((FilePosition = __PHYSFS_platformTell(opaque)) != 0)
      {
!         /* Non-zero if EOF is equal to the file length */
!         retval = FilePosition == __PHYSFS_platformFileLength(opaque);
      }
  
***************
*** 809,823 ****
  }
  
- /*
-  * Remove a file or directory entry in the actual filesystem. (path) is
-  *  specified in platform-dependent notation. Note that this deletes files
-  *  _and_ directories, so you might need to do some determination.
-  *  Non-empty directories should report an error and not delete themselves
-  *  or their contents.
-  *
-  * Deleting a symlink should remove the link, not what it points to.
-  *
-  * On error, return zero and set the error message. Return non-zero on 
success.
-  */
  int __PHYSFS_platformDelete(const char *path)
  {
--- 872,875 ----
***************
*** 860,869 ****
      {
          /* Our wait failed for some unknown reason */
!         retval = 1;
      }
      else
      {
          /* Good to go */
!         retval = 0;
      }
  
--- 912,921 ----
      {
          /* Our wait failed for some unknown reason */
!         retval = 0;
      }
      else
      {
          /* Good to go */
!         retval = 1;
      }
  
***************
*** 875,878 ****
--- 927,971 ----
      ReleaseMutex((HANDLE)mutex);
  }
+ 
+ static time_t FileTimeToTimeT(FILETIME *ft)
+ {
+     SYSTEMTIME st_utc;
+     SYSTEMTIME st_localtz;
+     TIME_ZONE_INFORMATION TimeZoneInfo;
+     struct tm tm;
+ 
+     FileTimeToSystemTime(ft, &st_utc);
+     GetTimeZoneInformation(&TimeZoneInfo);
+     SystemTimeToTzSpecificLocalTime(&TimeZoneInfo, &st_utc, &st_localtz);
+ 
+     tm.tm_sec = st_localtz.wSecond;
+     tm.tm_min = st_localtz.wMinute;
+     tm.tm_hour = st_localtz.wHour;
+     tm.tm_mday = st_localtz.wDay;
+     tm.tm_mon = st_localtz.wMonth - 1;
+     tm.tm_year = st_localtz.wYear - 1900;
+     tm.tm_wday = st_localtz.wDayOfWeek;
+     tm.tm_yday = -1;
+     tm.tm_isdst = -1;
+     return mktime(&tm);
+ } /* FileTimeToTimeT */
+ 
+ PHYSFS_sint64 __PHYSFS_platformGetLastModTime(const char *fname)
+ {
+     WIN32_FILE_ATTRIBUTE_DATA AttributeData;
+ 
+     GetFileAttributesEx(fname, GetFileExInfoStandard, &AttributeData);
+     /* 0 return value indicates an error or not supported */
+     if(AttributeData.ftLastWriteTime.dwHighDateTime == 0 &&
+         AttributeData.ftLastWriteTime.dwLowDateTime == 0)
+     {
+         /* Return error */
+         BAIL_MACRO(win32strerror(), -1);
+     }
+ 
+     /* Return UNIX time_t version of last write time */
+     return (PHYSFS_sint64)FileTimeToTimeT(&AttributeData.ftLastWriteTime);
+     /*return (PHYSFS_sint64)FileTimeToTimeT(&AttributeData.ftCreationTime);*/
+ } /* __PHYSFS_platformGetLastModTime */
  
  /* end of win32.c ... */




reply via email to

[Prev in Thread] Current Thread [Next in Thread]