physfs.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698
  1. /**
  2. * PhysicsFS; a portable, flexible file i/o abstraction.
  3. *
  4. * Documentation is in physfs.h. It's verbose, honest. :)
  5. *
  6. * Please see the file LICENSE in the source's root directory.
  7. *
  8. * This file written by Ryan C. Gordon.
  9. */
  10. #include <stdio.h>
  11. #include <stdlib.h>
  12. #include <string.h>
  13. #include <assert.h>
  14. #include "physfs.h"
  15. typedef struct __PHYSFS_ERRMSGTYPE__
  16. {
  17. int tid;
  18. int errorAvailable;
  19. char errorString[80];
  20. struct __PHYSFS_ERRMSGTYPE__ *next;
  21. } ErrMsg;
  22. /* !!!
  23. typedef struct __PHYSFS_READER__
  24. {
  25. } Reader;
  26. */
  27. typedef struct __PHYSFS_SEARCHDIRINFO__
  28. {
  29. char *dirName;
  30. Reader *reader;
  31. struct __PHYSFS_SEARCHDIRINFO__ *next;
  32. } SearchDirInfo;
  33. static int initialized = 0;
  34. static ErrMsg **errorMessages = NULL; /* uses list functions. */
  35. static char **searchPath = NULL; /* uses list functions. */
  36. static char *baseDir = NULL;
  37. static char *writeDir = NULL;
  38. static const PHYSFS_ArchiveInfo *supported_types[] =
  39. {
  40. #if (defined PHYSFS_SUPPORTS_ZIP)
  41. { "ZIP", "PkZip/WinZip/Info-Zip compatible" },
  42. #endif
  43. NULL
  44. };
  45. /* error messages... */
  46. #define ERR_IS_INITIALIZED "Already initialized"
  47. #define ERR_NOT_INITIALIZED "Not initialized"
  48. #define ERR_INVALID_ARGUMENT "Invalid argument"
  49. #define ERR_FILES_OPEN_WRITE "Files still open for writing"
  50. #define ERR_NO_DIR_CREATE "Failed to create directories"
  51. #define ERR_OUT_OF_MEMORY "Out of memory"
  52. #define ERR_NOT_IN_SEARCH_PATH "No such entry in search path"
  53. /* This gets used all over for lessening code clutter. */
  54. #define BAIL_IF_MACRO(cond, err, rc) if (cond) { setError(err); return(rc); }
  55. static ErrMsg *findErrorForCurrentThread(void)
  56. {
  57. ErrMsg *i;
  58. int tid;
  59. if (errorMessages != NULL)
  60. {
  61. tid = __PHYSFS_platformGetThreadID();
  62. for (i = errorMessages; i != NULL; i = i->next)
  63. {
  64. if (i->tid == tid)
  65. return(i);
  66. } /* for */
  67. } /* if */
  68. return(NULL); /* no error available. */
  69. } /* findErrorForCurrentThread */
  70. static void setError(char *str)
  71. {
  72. ErrMsg *err = findErrorForCurrentThread();
  73. if (err == NULL)
  74. {
  75. err = (ErrMsg *) malloc(sizeof (ErrMsg));
  76. if (err == NULL)
  77. return; /* uhh...? */
  78. err->next = errorMessages;
  79. if (errorMessages == NULL)
  80. errorMessages = err;
  81. err->tid = __PHYSFS_platformGetThreadID();
  82. } /* if */
  83. err->errorAvailable = 1;
  84. strncpy(err->errorString, str, sizeof (err->errorString));
  85. err->errorString[sizeof (err->errorString) - 1] = '\0';
  86. } /* setError */
  87. const char *PHYSFS_getLastError(void)
  88. {
  89. ErrMsg *err = findErrorForCurrentThread();
  90. if ((err == NULL) || (!err->errorAvailable))
  91. return(NULL);
  92. err->errorAvailable = 0;
  93. return(err->errorString);
  94. } /* PHYSFS_getLastError */
  95. void PHYSFS_getLinkedVersion(PHYSFS_Version *ver)
  96. {
  97. if (ver != NULL)
  98. {
  99. ver->major = PHYSFS_VER_MAJOR;
  100. ver->minor = PHYSFS_VER_MINOR;
  101. ver->patch = PHYSFS_VER_PATCH;
  102. } /* if */
  103. } /* PHYSFS_getLinkedVersion */
  104. int PHYSFS_init(const char *argv0)
  105. {
  106. BAIL_IF_MACRO(initialized, ERR_IS_INITIALIZED, 0);
  107. BAIL_IF_MACRO(argv0 == NULL, ERR_INVALID_ARGUMENT, 0);
  108. baseDir = calculateBaseDir();
  109. initialized = 1;
  110. return(1);
  111. } /* PHYSFS_init */
  112. static void freeSearchDir(SearchDirInfo *sdi)
  113. {
  114. assert(sdi != NULL);
  115. freeReader(sdi->reader);
  116. free(sdi->dirName);
  117. free(sdi);
  118. } /* freeSearchDir */
  119. static void freeSearchPath(void)
  120. {
  121. SearchDirInfo *i;
  122. SearchDirInfo *next = NULL;
  123. if (searchPath != NULL)
  124. {
  125. for (i = searchPath; i != NULL; i = next)
  126. {
  127. next = i;
  128. freeSearchDir(i);
  129. } /* for */
  130. searchPath = NULL;
  131. } /* if */
  132. } /* freeSearchPath */
  133. void PHYSFS_deinit(void)
  134. {
  135. BAIL_IF_MACRO(!initialized, ERR_NOT_INITIALIZED, 0);
  136. /* close/cleanup open handles. */
  137. if (baseDir != NULL)
  138. free(baseDir);
  139. PHYSFS_setWriteDir(NULL);
  140. freeSearchPath();
  141. freeErrorMessages();
  142. initialized = 0;
  143. return(1);
  144. } /* PHYSFS_deinit */
  145. const PHYSFS_ArchiveInfo **PHYSFS_supportedArchiveTypes(void)
  146. {
  147. return(supported_types);
  148. } /* PHYSFS_supportedArchiveTypes */
  149. void PHYSFS_freeList(void *list)
  150. {
  151. void **i;
  152. for (i = (void **) list; *i != NULL; i++)
  153. free(*i);
  154. free(list);
  155. } /* PHYSFS_freeList */
  156. const char *PHYSFS_getDirSeparator(void)
  157. {
  158. return(__PHYSFS_pathSeparator);
  159. } /* PHYSFS_getDirSeparator */
  160. char **PHYSFS_getCdRomDirs(void)
  161. {
  162. return(__PHYSFS_platformDetectAvailableCDs());
  163. } /* PHYSFS_getCdRomDirs */
  164. const char *PHYSFS_getBaseDir(void)
  165. {
  166. return(baseDir); /* this is calculated in PHYSFS_init()... */
  167. } /* PHYSFS_getBaseDir */
  168. const char *PHYSFS_getUserDir(void)
  169. {
  170. return(__PHYSFS_platformGetUserDir());
  171. } /* PHYSFS_getUserDir */
  172. const char *PHYSFS_getWriteDir(void)
  173. {
  174. return(writeDir);
  175. } /* PHYSFS_getWriteDir */
  176. int PHYSFS_setWriteDir(const char *newDir)
  177. {
  178. BAIL_IF_MACRO(openWriteCount > 0, ERR_FILES_OPEN_WRITE, 0);
  179. if (writeDir != NULL)
  180. {
  181. free(writeDir);
  182. writeDir = NULL;
  183. } /* if */
  184. if (newDir == NULL) /* we're done already! */
  185. return(1);
  186. BAIL_IF_MACRO(!createDirs_dependent(newDir), ERR_NO_DIR_CREATE, 0);
  187. writeDir = malloc(strlen(newDir) + 1);
  188. BAIL_IF_MACRO(writeDir == NULL, ERR_OUT_OF_MEMORY, 0);
  189. strcpy(writeDir, newDir);
  190. return(1);
  191. } /* PHYSFS_setWriteDir */
  192. int PHYSFS_addToSearchPath(const char *newDir, int appendToPath)
  193. {
  194. char *str = NULL;
  195. SearchDirInfo *sdi = NULL;
  196. __PHYSFS_Reader *reader = NULL;
  197. BAIL_IF_MACRO(newDir == NULL, ERR_INVALID_ARGUMENT, 0);
  198. reader = getReader(newDir); /* This sets the error message. */
  199. if (reader == NULL)
  200. return(0);
  201. sdi = (SearchDirInfo *) malloc(sizeof (SearchDirInfo));
  202. BAIL_IF_MACRO(sdi == NULL, ERR_OUT_OF_MEMORY, 0);
  203. sdi->dirName = (char *) malloc(strlen(newDir) + 1);
  204. if (sdi->dirName == NULL)
  205. {
  206. free(sdi);
  207. freeReader(reader);
  208. setError(ERR_OUT_OF_MEMORY);
  209. return(0);
  210. } /* if */
  211. sdi->reader = reader;
  212. strcpy(sdi->dirName, newDir);
  213. if (appendToPath)
  214. {
  215. sdi->next = searchPath;
  216. searchPath = sdi;
  217. } /* if */
  218. else
  219. {
  220. SearchDirInfo *i = searchPath;
  221. SearchDirInfo *prev = NULL;
  222. sdi->next = NULL;
  223. while (i != NULL)
  224. prev = i;
  225. if (prev == NULL)
  226. searchPath = sdi;
  227. else
  228. prev->next = sdi;
  229. } /* else */
  230. return(1);
  231. } /* PHYSFS_addToSearchPath */
  232. int PHYSFS_removeFromSearchPath(const char *oldDir)
  233. {
  234. SearchDirInfo *i;
  235. SearchDirInfo *prev = NULL;
  236. BAIL_IF_MACRO(oldDir == NULL, ERR_INVALID_ARGUMENT, 0);
  237. for (i = searchPath; i != NULL; i = i->next)
  238. {
  239. if (strcmp(i->dirName, oldDir) == 0)
  240. {
  241. if (prev == NULL)
  242. searchPath = i->next;
  243. else
  244. prev->next = i->next;
  245. freeSearchDir(i);
  246. return(1);
  247. } /* if */
  248. prev = i;
  249. } /* for */
  250. setError(ERR_NOT_IN_SEARCH_PATH);
  251. return(0);
  252. } /* PHYSFS_removeFromSearchPath */
  253. char **PHYSFS_getSearchPath(void)
  254. {
  255. int count = 1;
  256. int x;
  257. SearchDirInfo *i;
  258. char **retval;
  259. for (i = searchPath; i != NULL; i = i->next)
  260. count++;
  261. retval = (char **) malloc(sizeof (char *) * count);
  262. BAIL_IF_MACRO(!retval, ERR_OUT_OF_MEMORY, NULL);
  263. count--;
  264. retval[count] = NULL;
  265. for (i = searchPath, x = 0; x < count; i = i->next, x++)
  266. {
  267. retval[x] = (char *) malloc(strlen(i->dirName) + 1);
  268. if (retval[x] == NULL) /* this is friggin' ugly. */
  269. {
  270. while (x > 0)
  271. {
  272. x--;
  273. free(retval[x]);
  274. } /* while */
  275. free(retval);
  276. setError(ERR_OUT_OF_MEMORY);
  277. return(NULL);
  278. } /* if */
  279. strcpy(retval[x], i->dirName);
  280. } /* for */
  281. return(retval);
  282. } /* PHYSFS_getSearchPath */
  283. /**
  284. * Helper function.
  285. *
  286. * Set up sane, default paths. The write path will be set to
  287. * "userpath/.appName", which is created if it doesn't exist.
  288. *
  289. * The above is sufficient to make sure your program's configuration directory
  290. * is separated from other clutter, and platform-independent. The period
  291. * before "mygame" even hides the directory on Unix systems.
  292. *
  293. * The search path will be:
  294. *
  295. * - The Write Dir (created if it doesn't exist)
  296. * - The Write Dir/appName (created if it doesn't exist)
  297. * - The Base Dir (PHYSFS_getBaseDir())
  298. * - The Base Dir/appName (if it exists)
  299. * - All found CD-ROM paths (optionally)
  300. * - All found CD-ROM paths/appName (optionally, and if they exist)
  301. *
  302. * These directories are then searched for files ending with the extension
  303. * (archiveExt), which, if they are valid and supported archives, will also
  304. * be added to the search path. If you specified "PKG" for (archiveExt), and
  305. * there's a file named data.PKG in the base dir, it'll be checked. Archives
  306. * can either be appended or prepended to the search path in alphabetical
  307. * order, regardless of which directories they were found in.
  308. *
  309. * All of this can be accomplished from the application, but this just does it
  310. * all for you. Feel free to add more to the search path manually, too.
  311. *
  312. * @param appName Program-specific name of your program, to separate it
  313. * from other programs using PhysicsFS.
  314. *
  315. * @param archiveExt File extention used by your program to specify an
  316. * archive. For example, Quake 3 uses "pk3", even though
  317. * they are just zipfiles. Specify NULL to not dig out
  318. * archives automatically.
  319. *
  320. * @param includeCdRoms Non-zero to include CD-ROMs in the search path, and
  321. * (if (archiveExt) != NULL) search them for archives.
  322. * This may cause a significant amount of blocking
  323. * while discs are accessed, and if there are no discs
  324. * in the drive (or even not mounted on Unix systems),
  325. * then they may not be made available anyhow. You may
  326. * want to specify zero and handle the disc setup
  327. * yourself.
  328. *
  329. * @param archivesFirst Non-zero to prepend the archives to the search path.
  330. * Zero to append them. Ignored if !(archiveExt).
  331. */
  332. void PHYSFS_setSaneConfig(const char *appName, const char *archiveExt,
  333. int includeCdRoms, int archivesFirst)
  334. {
  335. } /* PHYSFS_setSaneConfig */
  336. /**
  337. * Create a directory. This is specified in platform-independent notation in
  338. * relation to the write path. All missing parent directories are also
  339. * created if they don't exist.
  340. *
  341. * So if you've got the write path set to "C:\mygame\writepath" and call
  342. * PHYSFS_mkdir("downloads/maps") then the directories
  343. * "C:\mygame\writepath\downloads" and "C:\mygame\writepath\downloads\maps"
  344. * will be created if possible. If the creation of "maps" fails after we
  345. * have successfully created "downloads", then the function leaves the
  346. * created directory behind and reports failure.
  347. *
  348. * @param dirName New path to create.
  349. * @return nonzero on success, zero on error. Specifics of the error can be
  350. * gleaned from PHYSFS_getLastError().
  351. */
  352. int PHYSFS_mkdir(const char *dirName)
  353. {
  354. } /* PHYSFS_mkdir */
  355. /**
  356. * Delete a file or directory. This is specified in platform-independent
  357. * notation in relation to the write path.
  358. *
  359. * A directory must be empty before this call can delete it.
  360. *
  361. * So if you've got the write path set to "C:\mygame\writepath" and call
  362. * PHYSFS_delete("downloads/maps/level1.map") then the file
  363. * "C:\mygame\writepath\downloads\maps\level1.map" is removed from the
  364. * physical filesystem, if it exists and the operating system permits the
  365. * deletion.
  366. *
  367. * Note that on Unix systems, deleting a file may be successful, but the
  368. * actual file won't be removed until all processes that have an open
  369. * filehandle to it (including your program) close their handles.
  370. *
  371. * @param filename Filename to delete.
  372. * @return nonzero on success, zero on error. Specifics of the error can be
  373. * gleaned from PHYSFS_getLastError().
  374. */
  375. int PHYSFS_delete(const char *filename)
  376. {
  377. } /* PHYSFS_delete */
  378. /**
  379. * Enable symbolic links. Some physical filesystems and archives contain
  380. * files that are just pointers to other files. On the physical filesystem,
  381. * opening such a link will (transparently) open the file that is pointed to.
  382. *
  383. * By default, PhysicsFS will check if a file is really a symlink during open
  384. * calls and fail if it is. Otherwise, the link could take you outside the
  385. * write and search paths, and compromise security.
  386. *
  387. * If you want to take that risk, call this function with a non-zero parameter.
  388. * Note that this is more for sandboxing a program's scripting language, in
  389. * case untrusted scripts try to compromise the system. Generally speaking,
  390. * a user could very well have a legitimate reason to set up a symlink, so
  391. * unless you feel there's a specific danger in allowing them, you should
  392. * permit them.
  393. *
  394. * Symbolic link permission can be enabled or disabled at any time, and is
  395. * disabled by default.
  396. *
  397. * @param allow nonzero to permit symlinks, zero to deny linking.
  398. */
  399. void PHYSFS_permitSymbolicLinks(int allow)
  400. {
  401. } /* PHYSFS_permitSymbolicLinks */
  402. /**
  403. * Figure out where in the search path a file resides. The file is specified
  404. * in platform-independent notation. The returned filename will be the
  405. * element of the search path where the file was found, which may be a
  406. * directory, or an archive. Even if there are multiple matches in different
  407. * parts of the search path, only the first one found is used, just like
  408. * when opening a file.
  409. *
  410. * So, if you look for "maps/level1.map", and C:\mygame is in your search
  411. * path and C:\mygame\maps\level1.map exists, then "C:\mygame" is returned.
  412. *
  413. * If a match is a symbolic link, and you've not explicitly permitted symlinks,
  414. * then it will be ignored, and the search for a match will continue.
  415. *
  416. * @param filename file to look for.
  417. * @return READ ONLY string of element of search path containing the
  418. * the file in question. NULL if not found.
  419. */
  420. const char *PHYSFS_getRealDir(const char *filename)
  421. {
  422. } /* PHYSFS_getRealDir */
  423. /**
  424. * Get a file listing of a search path's directory. Matching directories are
  425. * interpolated. That is, if "C:\mypath" is in the search path and contains a
  426. * directory "savegames" that contains "x.sav", "y.sav", and "z.sav", and
  427. * there is also a "C:\userpath" in the search path that has a "savegames"
  428. * subdirectory with "w.sav", then the following code:
  429. *
  430. * ------------------------------------------------
  431. * char **rc = PHYSFS_enumerateFiles("savegames");
  432. * char **i;
  433. *
  434. * for (i = rc; *i != NULL; i++)
  435. * printf("We've got [%s].\n", *i);
  436. *
  437. * PHYSFS_freeList(rc);
  438. * ------------------------------------------------
  439. *
  440. * ...will print:
  441. *
  442. * ------------------------------------------------
  443. * We've got [x.sav].
  444. * We've got [y.sav].
  445. * We've got [z.sav].
  446. * We've got [w.sav].
  447. * ------------------------------------------------
  448. *
  449. * Don't forget to call PHYSFS_freeList() with the return value from this
  450. * function when you are done with it.
  451. *
  452. * @param path directory in platform-independent notation to enumerate.
  453. * @return Null-terminated array of null-terminated strings.
  454. */
  455. char **PHYSFS_enumerateFiles(const char *path)
  456. {
  457. } /* PHYSFS_enumerateFiles */
  458. /**
  459. * Open a file for writing, in platform-independent notation and in relation
  460. * to the write path as the root of the writable filesystem. The specified
  461. * file is created if it doesn't exist. If it does exist, it is truncated to
  462. * zero bytes, and the writing offset is set to the start.
  463. *
  464. * @param filename File to open.
  465. * @return A valid PhysicsFS filehandle on success, NULL on error. Specifics
  466. * of the error can be gleaned from PHYSFS_getLastError().
  467. */
  468. PHYSFS_file *PHYSFS_openWrite(const char *filename)
  469. {
  470. } /* PHYSFS_openWrite */
  471. /**
  472. * Open a file for writing, in platform-independent notation and in relation
  473. * to the write path as the root of the writable filesystem. The specified
  474. * file is created if it doesn't exist. If it does exist, the writing offset
  475. * is set to the end of the file, so the first write will be the byte after
  476. * the end.
  477. *
  478. * @param filename File to open.
  479. * @return A valid PhysicsFS filehandle on success, NULL on error. Specifics
  480. * of the error can be gleaned from PHYSFS_getLastError().
  481. */
  482. PHYSFS_file *PHYSFS_openAppend(const char *filename)
  483. {
  484. } /* PHYSFS_openAppend */
  485. /**
  486. * Open a file for reading, in platform-independent notation. The search path
  487. * is checked one at a time until a matching file is found, in which case an
  488. * abstract filehandle is associated with it, and reading may be done.
  489. * The reading offset is set to the first byte of the file.
  490. *
  491. * @param filename File to open.
  492. * @return A valid PhysicsFS filehandle on success, NULL on error. Specifics
  493. * of the error can be gleaned from PHYSFS_getLastError().
  494. */
  495. PHYSFS_file *PHYSFS_openRead(const char *filename)
  496. {
  497. } /* PHYSFS_openRead */
  498. /**
  499. * Close a PhysicsFS filehandle. This call is capable of failing if the
  500. * operating system was buffering writes to this file, and (now forced to
  501. * write those changes to physical media) can not store the data for any
  502. * reason. In such a case, the filehandle stays open. A well-written program
  503. * should ALWAYS check the return value from the close call in addition to
  504. * every writing call!
  505. *
  506. * @param handle handle returned from PHYSFS_open*().
  507. * @return nonzero on success, zero on error. Specifics of the error can be
  508. * gleaned from PHYSFS_getLastError().
  509. */
  510. int PHYSFS_close(PHYSFS_file *handle)
  511. {
  512. } /* PHYSFS_close */
  513. /**
  514. * Read data from a PhysicsFS filehandle. The file must be opened for reading.
  515. *
  516. * @param handle handle returned from PHYSFS_openRead().
  517. * @param buffer buffer to store read data into.
  518. * @param objSize size in bytes of objects being read from (handle).
  519. * @param objCount number of (objSize) objects to read from (handle).
  520. * @return number of objects read. PHYSFS_getLastError() can shed light on
  521. * the reason this might be < (objCount), as can PHYSFS_eof().
  522. */
  523. int PHYSFS_read(PHYSFS_file *handle, void *buffer,
  524. unsigned int objSize, unsigned int objCount)
  525. {
  526. } /* PHYSFS_read */
  527. /**
  528. * Write data to a PhysicsFS filehandle. The file must be opened for writing.
  529. *
  530. * @param handle retval from PHYSFS_openWrite() or PHYSFS_openAppend().
  531. * @param buffer buffer to store read data into.
  532. * @param objSize size in bytes of objects being read from (handle).
  533. * @param objCount number of (objSize) objects to read from (handle).
  534. * @return number of objects read. PHYSFS_getLastError() can shed light on
  535. * the reason this might be < (objCount).
  536. */
  537. int PHYSFS_write(PHYSFS_file *handle, void *buffer,
  538. unsigned int objSize, unsigned int objCount)
  539. {
  540. } /* PHYSFS_write */
  541. /**
  542. * Determine if the end of file has been reached in a PhysicsFS filehandle.
  543. *
  544. * @param handle handle returned from PHYSFS_openRead().
  545. * @return nonzero if EOF, zero if not.
  546. */
  547. int PHYSFS_eof(PHYSFS_file *handle)
  548. {
  549. } /* PHYSFS_eof */
  550. /**
  551. * Determine current position within a PhysicsFS filehandle.
  552. *
  553. * @param handle handle returned from PHYSFS_open*().
  554. * @return offset in bytes from start of file. -1 if error occurred.
  555. * Specifics of the error can be gleaned from PHYSFS_getLastError().
  556. */
  557. int PHYSFS_tell(PHYSFS_file *handle)
  558. {
  559. } /* PHYSFS_tell */
  560. /**
  561. * Seek to a new position within a PhysicsFS filehandle. The next read or write
  562. * will occur at that place. Seeking past the beginning or end of the file is
  563. * not allowed.
  564. *
  565. * @param handle handle returned from PHYSFS_open*().
  566. * @param pos number of bytes from start of file to seek to.
  567. * @return nonzero on success, zero on error. Specifics of the error can be
  568. * gleaned from PHYSFS_getLastError().
  569. */
  570. int PHYSFS_seek(PHYSFS_file *handle, int pos)
  571. {
  572. } /* PHYSFS_seek */
  573. /* end of physfs.h ... */