2001-07-06 04:32:29 +02:00
|
|
|
/*
|
|
|
|
* Internal function/structure declaration. Do NOT include in your
|
|
|
|
* application.
|
|
|
|
*
|
|
|
|
* Please see the file LICENSE in the source's root directory.
|
|
|
|
*
|
|
|
|
* This file written by Ryan C. Gordon.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _INCLUDE_PHYSFS_INTERNAL_H_
|
|
|
|
#define _INCLUDE_PHYSFS_INTERNAL_H_
|
|
|
|
|
|
|
|
#ifndef __PHYSICSFS_INTERNAL__
|
|
|
|
#error Do not include this header from your applications.
|
|
|
|
#endif
|
|
|
|
|
2001-07-07 05:52:43 +02:00
|
|
|
struct __PHYSFS_DIRHANDLE__;
|
2001-07-06 10:47:23 +02:00
|
|
|
struct __PHYSFS_FILEFUNCTIONS__;
|
2001-07-06 04:32:29 +02:00
|
|
|
|
2001-07-08 05:25:12 +02:00
|
|
|
|
|
|
|
typedef struct __PHYSFS_LINKEDSTRINGLIST__
|
|
|
|
{
|
|
|
|
char *str;
|
|
|
|
struct __PHYSFS_LINKEDSTRINGLIST__ *next;
|
|
|
|
} LinkedStringList;
|
|
|
|
|
|
|
|
|
2001-07-06 04:32:29 +02:00
|
|
|
typedef struct __PHYSFS_FILEHANDLE__
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* This is reserved for the driver to store information.
|
|
|
|
*/
|
|
|
|
void *opaque;
|
|
|
|
|
|
|
|
/*
|
2001-07-06 10:47:23 +02:00
|
|
|
* This should be the DirHandle that created this FileHandle.
|
2001-07-06 04:32:29 +02:00
|
|
|
*/
|
2001-07-07 05:52:43 +02:00
|
|
|
const struct __PHYSFS_DIRHANDLE__ *dirHandle;
|
2001-07-06 04:32:29 +02:00
|
|
|
|
2001-07-06 10:47:23 +02:00
|
|
|
/*
|
|
|
|
* Pointer to the file i/o functions for this filehandle.
|
|
|
|
*/
|
|
|
|
const struct __PHYSFS_FILEFUNCTIONS__ *funcs;
|
|
|
|
} FileHandle;
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct __PHYSFS_FILEFUNCTIONS__
|
|
|
|
{
|
2001-07-06 04:32:29 +02:00
|
|
|
/*
|
|
|
|
* Read more from the file.
|
2001-07-07 05:52:43 +02:00
|
|
|
* Returns number of objects of (objSize) bytes read from file, -1
|
|
|
|
* if complete failure.
|
|
|
|
* On failure, call __PHYSFS_setError().
|
2001-07-06 04:32:29 +02:00
|
|
|
*/
|
2001-07-06 10:47:23 +02:00
|
|
|
int (*read)(FileHandle *handle, void *buffer,
|
2001-07-06 04:32:29 +02:00
|
|
|
unsigned int objSize, unsigned int objCount);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Write more to the file. Archives don't have to implement this.
|
|
|
|
* (Set it to NULL if not implemented).
|
2001-07-07 05:52:43 +02:00
|
|
|
* Returns number of objects of (objSize) bytes written to file, -1
|
|
|
|
* if complete failure.
|
|
|
|
* On failure, call __PHYSFS_setError().
|
2001-07-06 04:32:29 +02:00
|
|
|
*/
|
2001-07-06 10:47:23 +02:00
|
|
|
int (*write)(FileHandle *handle, void *buffer,
|
2001-07-06 04:32:29 +02:00
|
|
|
unsigned int objSize, unsigned int objCount);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Returns non-zero if at end of file.
|
|
|
|
*/
|
2001-07-06 10:47:23 +02:00
|
|
|
int (*eof)(FileHandle *handle);
|
2001-07-06 04:32:29 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Returns byte offset from start of file.
|
|
|
|
*/
|
2001-07-06 10:47:23 +02:00
|
|
|
int (*tell)(FileHandle *handle);
|
2001-07-06 04:32:29 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Move read/write pointer to byte offset from start of file.
|
|
|
|
* Returns non-zero on success, zero on error.
|
2001-07-07 05:52:43 +02:00
|
|
|
* On failure, call __PHYSFS_setError().
|
2001-07-06 04:32:29 +02:00
|
|
|
*/
|
2001-07-06 10:47:23 +02:00
|
|
|
int (*seek)(FileHandle *handle, int offset);
|
2001-07-06 04:32:29 +02:00
|
|
|
|
2001-07-09 06:15:35 +02:00
|
|
|
/*
|
|
|
|
* Return number of bytes available in the file, or -1 if you
|
|
|
|
* aren't able to determine.
|
|
|
|
* On failure, call __PHYSFS_setError().
|
|
|
|
*/
|
|
|
|
int (*fileLength)(FileHandle *handle);
|
|
|
|
|
2001-07-06 04:32:29 +02:00
|
|
|
/*
|
2001-07-06 10:47:23 +02:00
|
|
|
* Close the file, and free the FileHandle structure (including "opaque").
|
2001-07-07 05:52:43 +02:00
|
|
|
* returns non-zero on success, zero if can't close file.
|
|
|
|
* On failure, call __PHYSFS_setError().
|
2001-07-06 04:32:29 +02:00
|
|
|
*/
|
2001-07-08 05:25:12 +02:00
|
|
|
int (*fileClose)(FileHandle *handle);
|
2001-07-06 10:47:23 +02:00
|
|
|
} FileFunctions;
|
2001-07-06 04:32:29 +02:00
|
|
|
|
|
|
|
|
2001-07-07 05:52:43 +02:00
|
|
|
typedef struct __PHYSFS_DIRHANDLE__
|
2001-07-06 04:32:29 +02:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
* This is reserved for the driver to store information.
|
|
|
|
*/
|
|
|
|
void *opaque;
|
|
|
|
|
2001-07-06 10:47:23 +02:00
|
|
|
/*
|
2001-07-07 05:52:43 +02:00
|
|
|
* Pointer to the directory i/o functions for this handle.
|
2001-07-06 10:47:23 +02:00
|
|
|
*/
|
|
|
|
const struct __PHYSFS_DIRFUNCTIONS__ *funcs;
|
|
|
|
} DirHandle;
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Symlinks should always be followed; PhysicsFS will use
|
|
|
|
* DirFunctions->isSymLink() and make a judgement on whether to
|
|
|
|
* continue to call other methods based on that.
|
|
|
|
*/
|
|
|
|
typedef struct __PHYSFS_DIRFUNCTIONS__
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Returns non-zero if (filename) is a valid archive that this
|
|
|
|
* driver can handle. This filename is in platform-dependent
|
2001-07-07 05:52:43 +02:00
|
|
|
* notation. forWriting is non-zero if this is to be used for
|
|
|
|
* the write directory, and zero if this is to be used for an
|
|
|
|
* element of the search path.
|
2001-07-06 10:47:23 +02:00
|
|
|
*/
|
2001-07-07 05:52:43 +02:00
|
|
|
int (*isArchive)(const char *filename, int forWriting);
|
2001-07-06 10:47:23 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Return a DirHandle for dir/archive (name).
|
|
|
|
* This filename is in platform-dependent notation.
|
2001-07-07 05:52:43 +02:00
|
|
|
* forWriting is non-zero if this is to be used for
|
|
|
|
* the write directory, and zero if this is to be used for an
|
|
|
|
* element of the search path.
|
|
|
|
* Returns NULL on failure, and calls __PHYSFS_setError().
|
2001-07-06 10:47:23 +02:00
|
|
|
*/
|
2001-07-07 05:52:43 +02:00
|
|
|
DirHandle *(*openArchive)(const char *name, int forWriting);
|
2001-07-06 10:47:23 +02:00
|
|
|
|
2001-07-06 04:32:29 +02:00
|
|
|
/*
|
2001-07-06 23:29:37 +02:00
|
|
|
* Returns a list of all files in dirname. Each element of this list
|
|
|
|
* (and its "str" field) will be deallocated with the system's free()
|
|
|
|
* function by the caller, so be sure to explicitly malloc() each
|
2001-07-16 19:36:28 +02:00
|
|
|
* chunk. Omit symlinks if (omitSymLinks) is non-zero.
|
2001-07-06 23:29:37 +02:00
|
|
|
* If you have a memory failure, return as much as you can.
|
2001-07-06 10:47:23 +02:00
|
|
|
* This dirname is in platform-independent notation.
|
2001-07-06 04:32:29 +02:00
|
|
|
*/
|
2001-07-16 19:36:28 +02:00
|
|
|
LinkedStringList *(*enumerateFiles)(DirHandle *r,
|
|
|
|
const char *dirname,
|
|
|
|
int omitSymLinks);
|
|
|
|
|
2001-07-06 04:32:29 +02:00
|
|
|
|
|
|
|
/*
|
2001-07-07 05:52:43 +02:00
|
|
|
* Returns non-zero if filename can be opened for reading.
|
2001-07-06 10:47:23 +02:00
|
|
|
* This filename is in platform-independent notation.
|
2001-07-06 04:32:29 +02:00
|
|
|
*/
|
2001-07-07 05:52:43 +02:00
|
|
|
int (*exists)(DirHandle *r, const char *name);
|
2001-07-06 04:32:29 +02:00
|
|
|
|
|
|
|
/*
|
2001-07-07 05:52:43 +02:00
|
|
|
* Returns non-zero if filename is really a directory.
|
2001-07-06 10:47:23 +02:00
|
|
|
* This filename is in platform-independent notation.
|
2001-07-06 04:32:29 +02:00
|
|
|
*/
|
2001-07-07 05:52:43 +02:00
|
|
|
int (*isDirectory)(DirHandle *r, const char *name);
|
2001-07-06 04:32:29 +02:00
|
|
|
|
|
|
|
/*
|
2001-07-07 05:52:43 +02:00
|
|
|
* Returns non-zero if filename is really a symlink.
|
2001-07-06 10:47:23 +02:00
|
|
|
* This filename is in platform-independent notation.
|
2001-07-06 04:32:29 +02:00
|
|
|
*/
|
2001-07-07 05:52:43 +02:00
|
|
|
int (*isSymLink)(DirHandle *r, const char *name);
|
2001-07-06 04:32:29 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Open file for reading, and return a FileHandle.
|
2001-07-06 10:47:23 +02:00
|
|
|
* This filename is in platform-independent notation.
|
2001-07-07 05:52:43 +02:00
|
|
|
* If you can't handle multiple opens of the same file,
|
|
|
|
* you can opt to fail for the second call.
|
2001-07-08 05:25:12 +02:00
|
|
|
* Fail if the file does not exist.
|
2001-07-07 05:52:43 +02:00
|
|
|
* Returns NULL on failure, and calls __PHYSFS_setError().
|
2001-07-06 10:47:23 +02:00
|
|
|
*/
|
|
|
|
FileHandle *(*openRead)(DirHandle *r, const char *filename);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Open file for writing, and return a FileHandle.
|
2001-07-08 05:25:12 +02:00
|
|
|
* If the file does not exist, it should be created. If it exists,
|
|
|
|
* it should be truncated to zero bytes. The writing
|
|
|
|
* offset should be the start of the file.
|
|
|
|
* This filename is in platform-independent notation.
|
2001-07-06 10:47:23 +02:00
|
|
|
* This method may be NULL.
|
2001-07-07 05:52:43 +02:00
|
|
|
* If you can't handle multiple opens of the same file,
|
|
|
|
* you can opt to fail for the second call.
|
|
|
|
* Returns NULL on failure, and calls __PHYSFS_setError().
|
2001-07-06 10:47:23 +02:00
|
|
|
*/
|
|
|
|
FileHandle *(*openWrite)(DirHandle *r, const char *filename);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Open file for appending, and return a FileHandle.
|
2001-07-08 05:25:12 +02:00
|
|
|
* If the file does not exist, it should be created. The writing
|
|
|
|
* offset should be the end of the file.
|
|
|
|
* This filename is in platform-independent notation.
|
2001-07-06 10:47:23 +02:00
|
|
|
* This method may be NULL.
|
2001-07-07 05:52:43 +02:00
|
|
|
* If you can't handle multiple opens of the same file,
|
|
|
|
* you can opt to fail for the second call.
|
|
|
|
* Returns NULL on failure, and calls __PHYSFS_setError().
|
2001-07-06 04:32:29 +02:00
|
|
|
*/
|
2001-07-06 10:47:23 +02:00
|
|
|
FileHandle *(*openAppend)(DirHandle *r, const char *filename);
|
2001-07-06 04:32:29 +02:00
|
|
|
|
2001-07-07 05:52:43 +02:00
|
|
|
/*
|
|
|
|
* Delete a file in the archive/directory.
|
|
|
|
* Return non-zero on success, zero on failure.
|
|
|
|
* This filename is in platform-independent notation.
|
|
|
|
* This method may be NULL.
|
|
|
|
* On failure, call __PHYSFS_setError().
|
|
|
|
*/
|
|
|
|
int (*remove)(DirHandle *r, const char *filename);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Create a directory in the archive/directory.
|
|
|
|
* If the application is trying to make multiple dirs, PhysicsFS
|
|
|
|
* will split them up into multiple calls before passing them to
|
|
|
|
* your driver.
|
|
|
|
* Return non-zero on success, zero on failure.
|
|
|
|
* This filename is in platform-independent notation.
|
|
|
|
* This method may be NULL.
|
|
|
|
* On failure, call __PHYSFS_setError().
|
|
|
|
*/
|
|
|
|
int (*mkdir)(DirHandle *r, const char *filename);
|
|
|
|
|
2001-07-06 04:32:29 +02:00
|
|
|
/*
|
2001-07-06 10:47:23 +02:00
|
|
|
* Close directories/archives, and free the handle, including
|
2001-07-06 04:32:29 +02:00
|
|
|
* the "opaque" entry. This should assume that it won't be called if
|
2001-07-06 10:47:23 +02:00
|
|
|
* there are still files open from this DirHandle.
|
2001-07-06 04:32:29 +02:00
|
|
|
*/
|
2001-07-08 05:25:12 +02:00
|
|
|
void (*dirClose)(DirHandle *r);
|
2001-07-06 10:47:23 +02:00
|
|
|
} DirFunctions;
|
2001-07-06 04:32:29 +02:00
|
|
|
|
|
|
|
|
|
|
|
/* error messages... */
|
|
|
|
#define ERR_IS_INITIALIZED "Already initialized"
|
|
|
|
#define ERR_NOT_INITIALIZED "Not initialized"
|
|
|
|
#define ERR_INVALID_ARGUMENT "Invalid argument"
|
2001-07-07 05:52:43 +02:00
|
|
|
#define ERR_FILES_STILL_OPEN "Files still open"
|
2001-07-06 04:32:29 +02:00
|
|
|
#define ERR_NO_DIR_CREATE "Failed to create directories"
|
|
|
|
#define ERR_OUT_OF_MEMORY "Out of memory"
|
|
|
|
#define ERR_NOT_IN_SEARCH_PATH "No such entry in search path"
|
|
|
|
#define ERR_NOT_SUPPORTED "Operation not supported"
|
2001-07-06 10:47:23 +02:00
|
|
|
#define ERR_UNSUPPORTED_ARCHIVE "Archive type unsupported"
|
2001-07-07 05:52:43 +02:00
|
|
|
#define ERR_NOT_A_HANDLE "Not a file handle"
|
|
|
|
#define ERR_INSECURE_FNAME "Insecure filename"
|
|
|
|
#define ERR_SYMLINK_DISALLOWED "Symbolic links are disabled"
|
|
|
|
#define ERR_NO_WRITE_DIR "Write directory is not set"
|
2001-07-07 11:05:19 +02:00
|
|
|
#define ERR_NO_SUCH_FILE "No such file"
|
2001-07-08 07:27:05 +02:00
|
|
|
#define ERR_PAST_EOF "Past end of file"
|
2001-07-08 12:58:10 +02:00
|
|
|
#define ERR_ARC_IS_READ_ONLY "Archive is read-only"
|
2001-07-15 11:27:41 +02:00
|
|
|
#define ERR_IO_ERROR "I/O error"
|
2001-07-23 06:47:08 +02:00
|
|
|
#define ERR_CANT_SET_WRITE_DIR "Can't set write directory"
|
|
|
|
#define ERR_TOO_MANY_SYMLINKS "Too many symbolic links"
|
2001-07-23 09:15:48 +02:00
|
|
|
#define ERR_COMPRESSION "(De)compression error"
|
2001-07-06 04:32:29 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Call this to set the message returned by PHYSFS_getLastError().
|
|
|
|
* Please only use the ERR_* constants above, or add new constants to the
|
|
|
|
* above group, but I want these all in one place.
|
2001-07-07 05:52:43 +02:00
|
|
|
*
|
|
|
|
* Calling this with a NULL argument is a safe no-op.
|
2001-07-06 04:32:29 +02:00
|
|
|
*/
|
|
|
|
void __PHYSFS_setError(const char *err);
|
|
|
|
|
|
|
|
|
2001-07-07 05:52:43 +02:00
|
|
|
/*
|
|
|
|
* Convert (dirName) to platform-dependent notation, then prepend (prepend)
|
|
|
|
* and append (append) to the converted string.
|
|
|
|
*
|
|
|
|
* So, on Win32, calling:
|
2001-07-08 05:25:12 +02:00
|
|
|
* __PHYSFS_convertToDependent("C:\", "my/files", NULL);
|
2001-07-07 05:52:43 +02:00
|
|
|
* ...will return the string "C:\my\files".
|
|
|
|
*
|
|
|
|
* This is a convenience function; you might want to hack something out that
|
|
|
|
* is less generic (and therefore more efficient).
|
|
|
|
*
|
|
|
|
* Be sure to free() the return value when done with it.
|
|
|
|
*/
|
2001-07-08 05:25:12 +02:00
|
|
|
char *__PHYSFS_convertToDependent(const char *prepend,
|
|
|
|
const char *dirName,
|
|
|
|
const char *append);
|
2001-07-07 05:52:43 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Verify that (fname) (in platform-independent notation), in relation
|
|
|
|
* to (h) is secure. That means that each element of fname is checked
|
|
|
|
* for symlinks (if they aren't permitted). Also, elements such as
|
|
|
|
* ".", "..", or ":" are flagged.
|
|
|
|
*
|
|
|
|
* Returns non-zero if string is safe, zero if there's a security issue.
|
|
|
|
* PHYSFS_getLastError() will specify what was wrong.
|
|
|
|
*/
|
|
|
|
int __PHYSFS_verifySecurity(DirHandle *h, const char *fname);
|
|
|
|
|
|
|
|
|
2001-08-23 17:23:21 +02:00
|
|
|
/* These get used all over for lessening code clutter. */
|
|
|
|
#define BAIL_MACRO(e, r) { __PHYSFS_setError(e); return r; }
|
2001-07-07 05:52:43 +02:00
|
|
|
#define BAIL_IF_MACRO(c, e, r) if (c) { __PHYSFS_setError(e); return r; }
|
2001-07-06 04:32:29 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*--------------------------------------------------------------------------*/
|
|
|
|
/*--------------------------------------------------------------------------*/
|
|
|
|
/*------------ ----------------*/
|
|
|
|
/*------------ You MUST implement the following functions ----------------*/
|
|
|
|
/*------------ if porting to a new platform. ----------------*/
|
2001-07-15 11:27:41 +02:00
|
|
|
/*------------ (see platform/unix.c for an example) ----------------*/
|
2001-07-06 04:32:29 +02:00
|
|
|
/*------------ ----------------*/
|
|
|
|
/*--------------------------------------------------------------------------*/
|
|
|
|
/*--------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The dir separator; "/" on unix, "\\" on win32, ":" on MacOS, etc...
|
|
|
|
* Obviously, this isn't a function, but it IS a null-terminated string.
|
|
|
|
*/
|
2001-07-07 05:52:43 +02:00
|
|
|
extern const char *__PHYSFS_platformDirSeparator;
|
2001-07-06 04:32:29 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Platform implementation of PHYSFS_getCdRomDirs()...
|
|
|
|
* See physfs.h. The retval should be freeable via PHYSFS_freeList().
|
|
|
|
*/
|
|
|
|
char **__PHYSFS_platformDetectAvailableCDs(void);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Calculate the base dir, if your platform needs special consideration.
|
|
|
|
* Just return NULL if the standard routines will suffice. (see
|
|
|
|
* calculateBaseDir() in physfs.c ...)
|
|
|
|
* Caller will free() the retval if it's not NULL.
|
|
|
|
*/
|
2001-07-08 15:57:28 +02:00
|
|
|
char *__PHYSFS_platformCalcBaseDir(const char *argv0);
|
2001-07-06 04:32:29 +02:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Get the platform-specific user name.
|
|
|
|
* Caller will free() the retval if it's not NULL. If it's NULL, the username
|
|
|
|
* will default to "default".
|
|
|
|
*/
|
|
|
|
char *__PHYSFS_platformGetUserName(void);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Get the platform-specific user dir.
|
|
|
|
* Caller will free() the retval if it's not NULL. If it's NULL, the userdir
|
|
|
|
* will default to basedir/username.
|
|
|
|
*/
|
|
|
|
char *__PHYSFS_platformGetUserDir(void);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Return a number that uniquely identifies the current thread.
|
|
|
|
* On a platform without threading, (1) will suffice. These numbers are
|
|
|
|
* arbitrary; the only requirement is that no two threads have the same
|
|
|
|
* number.
|
|
|
|
*/
|
|
|
|
int __PHYSFS_platformGetThreadID(void);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This is a pass-through to whatever stricmp() is called on your platform.
|
|
|
|
*/
|
|
|
|
int __PHYSFS_platformStricmp(const char *str1, const char *str2);
|
|
|
|
|
2001-07-08 05:25:12 +02:00
|
|
|
/*
|
|
|
|
* Return non-zero if filename (in platform-dependent notation) exists.
|
|
|
|
* Symlinks should be followed; if what the symlink points to is missing,
|
|
|
|
* then the retval is false.
|
|
|
|
*/
|
|
|
|
int __PHYSFS_platformExists(const char *fname);
|
|
|
|
|
2001-07-06 10:47:23 +02:00
|
|
|
/*
|
|
|
|
* Return non-zero if filename (in platform-dependent notation) is a symlink.
|
|
|
|
*/
|
2001-07-08 05:25:12 +02:00
|
|
|
int __PHYSFS_platformIsSymLink(const char *fname);
|
2001-07-06 10:47:23 +02:00
|
|
|
|
2001-07-07 05:52:43 +02:00
|
|
|
/*
|
|
|
|
* Return non-zero if filename (in platform-dependent notation) is a symlink.
|
2001-07-08 05:25:12 +02:00
|
|
|
* Symlinks should be followed; if what the symlink points to is missing,
|
|
|
|
* or isn't a directory, then the retval is false.
|
2001-07-07 05:52:43 +02:00
|
|
|
*/
|
|
|
|
int __PHYSFS_platformIsDirectory(const char *fname);
|
|
|
|
|
2001-07-08 05:25:12 +02:00
|
|
|
/*
|
|
|
|
* Convert (dirName) to platform-dependent notation, then prepend (prepend)
|
|
|
|
* and append (append) to the converted string.
|
|
|
|
*
|
|
|
|
* So, on Win32, calling:
|
|
|
|
* __PHYSFS_platformCvtToDependent("C:\", "my/files", NULL);
|
|
|
|
* ...will return the string "C:\my\files".
|
|
|
|
*
|
|
|
|
* This can be implemented in a platform-specific manner, so you can get
|
|
|
|
* get a speed boost that the default implementation can't, since
|
|
|
|
* you can make assumptions about the size of strings, etc..
|
|
|
|
*
|
|
|
|
* Platforms that choose not to implement this may just call
|
|
|
|
* __PHYSFS_convertToDependent() as a passthrough.
|
|
|
|
*
|
|
|
|
* Be sure to free() the return value when done with it.
|
|
|
|
*/
|
|
|
|
char *__PHYSFS_platformCvtToDependent(const char *prepend,
|
|
|
|
const char *dirName,
|
|
|
|
const char *append);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Make the current thread give up a timeslice. This is called in a loop
|
|
|
|
* while waiting for various external forces to get back to us.
|
|
|
|
*/
|
|
|
|
void __PHYSFS_platformTimeslice(void);
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Enumerate a directory of files. This follows the rules for the
|
|
|
|
* DirFunctions->enumerateFiles() method (see above), except that the
|
|
|
|
* (dirName) that is passed to this function is converted to
|
|
|
|
* platform-DEPENDENT notation by the caller. The DirFunctions version
|
2001-07-16 19:36:28 +02:00
|
|
|
* uses platform-independent notation. Note that ".", "..", and other
|
|
|
|
* metaentries should always be ignored.
|
2001-07-08 05:25:12 +02:00
|
|
|
*/
|
2001-07-16 19:36:28 +02:00
|
|
|
LinkedStringList *__PHYSFS_platformEnumerateFiles(const char *dirname,
|
|
|
|
int omitSymLinks);
|
2001-07-08 05:25:12 +02:00
|
|
|
|
2001-07-06 04:32:29 +02:00
|
|
|
|
2001-07-09 06:15:35 +02:00
|
|
|
/*
|
|
|
|
* Determine the current size of a file, in bytes, from a stdio FILE *.
|
|
|
|
* Return -1 if you can't do it, and call __PHYSFS_setError().
|
|
|
|
*/
|
|
|
|
int __PHYSFS_platformFileLength(FILE *handle);
|
|
|
|
|
|
|
|
|
2001-07-16 16:36:02 +02:00
|
|
|
/*
|
|
|
|
* Get the current working directory. The return value should be an
|
|
|
|
* absolute path in platform-dependent notation. The caller will deallocate
|
|
|
|
* the return value with the standard C runtime free() function when it
|
|
|
|
* is done with it.
|
|
|
|
* On error, return NULL and set the error message.
|
|
|
|
*/
|
|
|
|
char *__PHYSFS_platformCurrentDir(void);
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Get the real physical path to a file. (path) is specified in
|
|
|
|
* platform-dependent notation, as should your return value be.
|
|
|
|
* All relative paths should be removed, leaving you with an absolute
|
|
|
|
* path. Symlinks should be resolved, too, so that the returned value is
|
|
|
|
* the most direct path to a file.
|
|
|
|
* The return value will be deallocated with the standard C runtime free()
|
|
|
|
* function when the caller is done with it.
|
|
|
|
* On error, return NULL and set the error message.
|
|
|
|
*/
|
|
|
|
char *__PHYSFS_platformRealPath(const char *path);
|
|
|
|
|
|
|
|
|
2001-08-23 17:23:21 +02:00
|
|
|
/*
|
|
|
|
* Make a directory in the actual filesystem. (path) is specified in
|
|
|
|
* platform-dependent notation. On error, return zero and set the error
|
|
|
|
* message. Return non-zero on success.
|
|
|
|
*/
|
|
|
|
int __PHYSFS_platformMkDir(const char *path);
|
|
|
|
|
|
|
|
|
2001-07-06 04:32:29 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* end of physfs_internal.h ... */
|
|
|
|
|