physfs_internal.h
changeset 240 052041af9001
parent 172 ebad22720e88
child 337 28500f02eb87
equal deleted inserted replaced
239:f5a5cbef2ee8 240:052041af9001
   172         /*
   172         /*
   173          * Returns non-zero if filename is really a symlink.
   173          * Returns non-zero if filename is really a symlink.
   174          *  This filename is in platform-independent notation.
   174          *  This filename is in platform-independent notation.
   175          */
   175          */
   176     int (*isSymLink)(DirHandle *r, const char *name);
   176     int (*isSymLink)(DirHandle *r, const char *name);
       
   177 
       
   178         /*
       
   179 	     * Retrieve the last modification time (mtime) of a file.
       
   180     	 *  Returns -1 on failure, or the file's mtime in seconds since
       
   181     	 *  the epoch (Jan 1, 1970) on success.
       
   182          *  This filename is in platform-independent notation.
       
   183     	 */
       
   184     PHYSFS_sint64 (*getLastModTime)(DirHandle *r, const char *filename);
   177 
   185 
   178         /*
   186         /*
   179          * Open file for reading, and return a FileHandle.
   187          * Open file for reading, and return a FileHandle.
   180          *  This filename is in platform-independent notation.
   188          *  This filename is in platform-independent notation.
   181          * If you can't handle multiple opens of the same file,
   189          * If you can't handle multiple opens of the same file,
   265 #define ERR_OS_ERROR             "Operating system reported error"
   273 #define ERR_OS_ERROR             "Operating system reported error"
   266 #define ERR_FILE_EXISTS          "File already exists"
   274 #define ERR_FILE_EXISTS          "File already exists"
   267 #define ERR_NOT_A_DIR            "Not a directory"
   275 #define ERR_NOT_A_DIR            "Not a directory"
   268 #define ERR_FILE_NOT_FOUND       "File not found"
   276 #define ERR_FILE_NOT_FOUND       "File not found"
   269 
   277 
       
   278 
   270 /*
   279 /*
   271  * Call this to set the message returned by PHYSFS_getLastError().
   280  * Call this to set the message returned by PHYSFS_getLastError().
   272  *  Please only use the ERR_* constants above, or add new constants to the
   281  *  Please only use the ERR_* constants above, or add new constants to the
   273  *  above group, but I want these all in one place.
   282  *  above group, but I want these all in one place.
   274  *
   283  *
   341  * Return zero if there was a catastrophic failure (which prevents you from
   350  * Return zero if there was a catastrophic failure (which prevents you from
   342  *  functioning at all), and non-zero otherwise.
   351  *  functioning at all), and non-zero otherwise.
   343  */
   352  */
   344 int __PHYSFS_platformInit(void);
   353 int __PHYSFS_platformInit(void);
   345 
   354 
       
   355 
   346 /*
   356 /*
   347  * Deinitialize the platform. This is called when PHYSFS_deinit() is called
   357  * Deinitialize the platform. This is called when PHYSFS_deinit() is called
   348  *  from the application. You can use this to clean up anything you've
   358  *  from the application. You can use this to clean up anything you've
   349  *  allocated in your platform driver.
   359  *  allocated in your platform driver.
   350  *
   360  *
   351  * Return zero if there was a catastrophic failure (which prevents you from
   361  * Return zero if there was a catastrophic failure (which prevents you from
   352  *  functioning at all), and non-zero otherwise.
   362  *  functioning at all), and non-zero otherwise.
   353  */
   363  */
   354 int __PHYSFS_platformDeinit(void);
   364 int __PHYSFS_platformDeinit(void);
   355 
   365 
       
   366 
   356 /*
   367 /*
   357  * Open a file for reading. (filename) is in platform-dependent notation. The
   368  * Open a file for reading. (filename) is in platform-dependent notation. The
   358  *  file pointer should be positioned on the first byte of the file.
   369  *  file pointer should be positioned on the first byte of the file.
   359  *
   370  *
   360  * The return value will be some platform-specific datatype that is opaque to
   371  * The return value will be some platform-specific datatype that is opaque to
   365  *  conditions in the archivers.
   376  *  conditions in the archivers.
   366  *
   377  *
   367  * Call __PHYSFS_setError() and return (NULL) if the file can't be opened.
   378  * Call __PHYSFS_setError() and return (NULL) if the file can't be opened.
   368  */
   379  */
   369 void *__PHYSFS_platformOpenRead(const char *filename);
   380 void *__PHYSFS_platformOpenRead(const char *filename);
       
   381 
   370 
   382 
   371 /*
   383 /*
   372  * Open a file for writing. (filename) is in platform-dependent notation. If
   384  * Open a file for writing. (filename) is in platform-dependent notation. If
   373  *  the file exists, it should be truncated to zero bytes, and if it doesn't
   385  *  the file exists, it should be truncated to zero bytes, and if it doesn't
   374  *  exist, it should be created as a zero-byte file. The file pointer should
   386  *  exist, it should be created as a zero-byte file. The file pointer should
   381  * Opening a file for write multiple times has undefined results.
   393  * Opening a file for write multiple times has undefined results.
   382  *
   394  *
   383  * Call __PHYSFS_setError() and return (NULL) if the file can't be opened.
   395  * Call __PHYSFS_setError() and return (NULL) if the file can't be opened.
   384  */
   396  */
   385 void *__PHYSFS_platformOpenWrite(const char *filename);
   397 void *__PHYSFS_platformOpenWrite(const char *filename);
       
   398 
   386 
   399 
   387 /*
   400 /*
   388  * Open a file for appending. (filename) is in platform-dependent notation. If
   401  * Open a file for appending. (filename) is in platform-dependent notation. If
   389  *  the file exists, the file pointer should be place just past the end of the
   402  *  the file exists, the file pointer should be place just past the end of the
   390  *  file, so that the first write will be one byte after the current end of
   403  *  file, so that the first write will be one byte after the current end of
   398  * Opening a file for append multiple times has undefined results.
   411  * Opening a file for append multiple times has undefined results.
   399  *
   412  *
   400  * Call __PHYSFS_setError() and return (NULL) if the file can't be opened.
   413  * Call __PHYSFS_setError() and return (NULL) if the file can't be opened.
   401  */
   414  */
   402 void *__PHYSFS_platformOpenAppend(const char *filename);
   415 void *__PHYSFS_platformOpenAppend(const char *filename);
       
   416 
   403 
   417 
   404 /*
   418 /*
   405  * Read more data from a platform-specific file handle. (opaque) should be
   419  * Read more data from a platform-specific file handle. (opaque) should be
   406  *  cast to whatever data type your platform uses. Read a maximum of (count)
   420  *  cast to whatever data type your platform uses. Read a maximum of (count)
   407  *  objects of (size) 8-bit bytes to the area pointed to by (buffer). If there
   421  *  objects of (size) 8-bit bytes to the area pointed to by (buffer). If there
   439  * On error, call __PHYSFS_setError() and return zero. On success, return
   453  * On error, call __PHYSFS_setError() and return zero. On success, return
   440  *  a non-zero value.
   454  *  a non-zero value.
   441  */
   455  */
   442 int __PHYSFS_platformSeek(void *opaque, PHYSFS_uint64 pos);
   456 int __PHYSFS_platformSeek(void *opaque, PHYSFS_uint64 pos);
   443 
   457 
       
   458 
   444 /*
   459 /*
   445  * Get the file pointer's position, in an 8-bit byte offset from the start of
   460  * Get the file pointer's position, in an 8-bit byte offset from the start of
   446  *  the file. (opaque) should be cast to whatever data type your platform
   461  *  the file. (opaque) should be cast to whatever data type your platform
   447  *  uses.
   462  *  uses.
   448  *
   463  *
   450  *
   465  *
   451  * On error, call __PHYSFS_setError() and return zero. On success, return
   466  * On error, call __PHYSFS_setError() and return zero. On success, return
   452  *  a non-zero value.
   467  *  a non-zero value.
   453  */
   468  */
   454 PHYSFS_sint64 __PHYSFS_platformTell(void *opaque);
   469 PHYSFS_sint64 __PHYSFS_platformTell(void *opaque);
       
   470 
   455 
   471 
   456 /*
   472 /*
   457  * Determine the current size of a file, in 8-bit bytes, from an open file.
   473  * Determine the current size of a file, in 8-bit bytes, from an open file.
   458  *
   474  *
   459  * The caller expects that this information may not be available for all
   475  * The caller expects that this information may not be available for all
   542  *  then the retval is false.
   558  *  then the retval is false.
   543  */
   559  */
   544 int __PHYSFS_platformExists(const char *fname);
   560 int __PHYSFS_platformExists(const char *fname);
   545 
   561 
   546 /*
   562 /*
       
   563  * Return the last modified time (in seconds since the epoch) of a file.
       
   564  *  Returns -1 on failure. (fname) is in platform-dependent notation.
       
   565  *  Symlinks should be followed; if what the symlink points to is missing,
       
   566  *  then the retval is -1.
       
   567  */
       
   568 PHYSFS_sint64 __PHYSFS_platformGetLastModTime(const char *fname);
       
   569 
       
   570 
       
   571 /*
   547  * Return non-zero if filename (in platform-dependent notation) is a symlink.
   572  * Return non-zero if filename (in platform-dependent notation) is a symlink.
   548  */
   573  */
   549 int __PHYSFS_platformIsSymLink(const char *fname);
   574 int __PHYSFS_platformIsSymLink(const char *fname);
       
   575 
   550 
   576 
   551 /*
   577 /*
   552  * Return non-zero if filename (in platform-dependent notation) is a symlink.
   578  * Return non-zero if filename (in platform-dependent notation) is a symlink.
   553  *  Symlinks should be followed; if what the symlink points to is missing,
   579  *  Symlinks should be followed; if what the symlink points to is missing,
   554  *  or isn't a directory, then the retval is false.
   580  *  or isn't a directory, then the retval is false.
   555  */
   581  */
   556 int __PHYSFS_platformIsDirectory(const char *fname);
   582 int __PHYSFS_platformIsDirectory(const char *fname);
   557 
   583 
       
   584 
   558 /*
   585 /*
   559  * Convert (dirName) to platform-dependent notation, then prepend (prepend)
   586  * Convert (dirName) to platform-dependent notation, then prepend (prepend)
   560  *  and append (append) to the converted string.
   587  *  and append (append) to the converted string.
   561  *
   588  *
   562  *  So, on Win32, calling:
   589  *  So, on Win32, calling:
   574  * Be sure to free() the return value when done with it.
   601  * Be sure to free() the return value when done with it.
   575  */
   602  */
   576 char *__PHYSFS_platformCvtToDependent(const char *prepend,
   603 char *__PHYSFS_platformCvtToDependent(const char *prepend,
   577                                       const char *dirName,
   604                                       const char *dirName,
   578                                       const char *append);
   605                                       const char *append);
       
   606 
   579 
   607 
   580 /*
   608 /*
   581  * Make the current thread give up a timeslice. This is called in a loop
   609  * Make the current thread give up a timeslice. This is called in a loop
   582  *  while waiting for various external forces to get back to us.
   610  *  while waiting for various external forces to get back to us.
   583  */
   611  */
   624  *  platform-dependent notation. On error, return zero and set the error
   652  *  platform-dependent notation. On error, return zero and set the error
   625  *  message. Return non-zero on success.
   653  *  message. Return non-zero on success.
   626  */
   654  */
   627 int __PHYSFS_platformMkDir(const char *path);
   655 int __PHYSFS_platformMkDir(const char *path);
   628 
   656 
       
   657 
   629 /*
   658 /*
   630  * Remove a file or directory entry in the actual filesystem. (path) is
   659  * Remove a file or directory entry in the actual filesystem. (path) is
   631  *  specified in platform-dependent notation. Note that this deletes files
   660  *  specified in platform-dependent notation. Note that this deletes files
   632  *  _and_ directories, so you might need to do some determination.
   661  *  _and_ directories, so you might need to do some determination.
   633  *  Non-empty directories should report an error and not delete themselves
   662  *  Non-empty directories should report an error and not delete themselves