1
0

physfs.h 67 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825
  1. /** \file physfs.h */
  2. /**
  3. * \mainpage PhysicsFS
  4. *
  5. * The latest version of PhysicsFS can be found at:
  6. * http://icculus.org/physfs/
  7. *
  8. * PhysicsFS; a portable, flexible file i/o abstraction.
  9. *
  10. * This API gives you access to a system file system in ways superior to the
  11. * stdio or system i/o calls. The brief benefits:
  12. *
  13. * - It's portable.
  14. * - It's safe. No file access is permitted outside the specified dirs.
  15. * - It's flexible. Archives (.ZIP files) can be used transparently as
  16. * directory structures.
  17. *
  18. * This system is largely inspired by Quake 3's PK3 files and the related
  19. * fs_* cvars. If you've ever tinkered with these, then this API will be
  20. * familiar to you.
  21. *
  22. * With PhysicsFS, you have a single writing directory and multiple
  23. * directories (the "search path") for reading. You can think of this as a
  24. * filesystem within a filesystem. If (on Windows) you were to set the
  25. * writing directory to "C:\MyGame\MyWritingDirectory", then no PHYSFS calls
  26. * could touch anything above this directory, including the "C:\MyGame" and
  27. * "C:\" directories. This prevents an application's internal scripting
  28. * language from piddling over c:\config.sys, for example. If you'd rather
  29. * give PHYSFS full access to the system's REAL file system, set the writing
  30. * dir to "C:\", but that's generally A Bad Thing for several reasons.
  31. *
  32. * Drive letters are hidden in PhysicsFS once you set up your initial paths.
  33. * The search path creates a single, hierarchical directory structure.
  34. * Not only does this lend itself well to general abstraction with archives,
  35. * it also gives better support to operating systems like MacOS and Unix.
  36. * Generally speaking, you shouldn't ever hardcode a drive letter; not only
  37. * does this hurt portability to non-Microsoft OSes, but it limits your win32
  38. * users to a single drive, too. Use the PhysicsFS abstraction functions and
  39. * allow user-defined configuration options, too. When opening a file, you
  40. * specify it like it was on a Unix filesystem: if you want to write to
  41. * "C:\MyGame\MyConfigFiles\game.cfg", then you might set the write dir to
  42. * "C:\MyGame" and then open "MyConfigFiles/game.cfg". This gives an
  43. * abstraction across all platforms. Specifying a file in this way is termed
  44. * "platform-independent notation" in this documentation. Specifying a
  45. * a filename in a form such as "C:\mydir\myfile" or
  46. * "MacOS hard drive:My Directory:My File" is termed "platform-dependent
  47. * notation". The only time you use platform-dependent notation is when
  48. * setting up your write directory and search path; after that, all file
  49. * access into those directories are done with platform-independent notation.
  50. *
  51. * All files opened for writing are opened in relation to the write directory,
  52. * which is the root of the writable filesystem. When opening a file for
  53. * reading, PhysicsFS goes through the search path. This is NOT the
  54. * same thing as the PATH environment variable. An application using
  55. * PhysicsFS specifies directories to be searched which may be actual
  56. * directories, or archive files that contain files and subdirectories of
  57. * their own. See the end of these docs for currently supported archive
  58. * formats.
  59. *
  60. * Once the search path is defined, you may open files for reading. If you've
  61. * got the following search path defined (to use a win32 example again):
  62. *
  63. * C:\mygame
  64. * C:\mygame\myuserfiles
  65. * D:\mygamescdromdatafiles
  66. * C:\mygame\installeddatafiles.zip
  67. *
  68. * Then a call to PHYSFS_openRead("textfiles/myfile.txt") (note the directory
  69. * separator, lack of drive letter, and lack of dir separator at the start of
  70. * the string; this is platform-independent notation) will check for
  71. * C:\mygame\textfiles\myfile.txt, then
  72. * C:\mygame\myuserfiles\textfiles\myfile.txt, then
  73. * D:\mygamescdromdatafiles\textfiles\myfile.txt, then, finally, for
  74. * textfiles\myfile.txt inside of C:\mygame\installeddatafiles.zip. Remember
  75. * that most archive types and platform filesystems store their filenames in
  76. * a case-sensitive manner, so you should be careful to specify it correctly.
  77. *
  78. * Files opened through PhysicsFS may NOT contain "." or ".." or ":" as dir
  79. * elements. Not only are these meaningless on MacOS and/or Unix, they are a
  80. * security hole. Also, symbolic links (which can be found in some archive
  81. * types and directly in the filesystem on Unix platforms) are NOT followed
  82. * until you call PHYSFS_permitSymbolicLinks(). That's left to your own
  83. * discretion, as following a symlink can allow for access outside the write
  84. * dir and search paths. There is no mechanism for creating new symlinks in
  85. * PhysicsFS.
  86. *
  87. * The write dir is not included in the search path unless you specifically
  88. * add it. While you CAN change the write dir as many times as you like,
  89. * you should probably set it once and stick to it. Remember that your
  90. * program will not have permission to write in every directory on Unix and
  91. * NT systems.
  92. *
  93. * All files are opened in binary mode; there is no endline conversion for
  94. * textfiles. Other than that, PhysicsFS has some convenience functions for
  95. * platform-independence. There is a function to tell you the current
  96. * platform's dir separator ("\\" on windows, "/" on Unix, ":" on MacOS),
  97. * which is needed only to set up your search/write paths. There is a
  98. * function to tell you what CD-ROM drives contain accessible discs, and a
  99. * function to recommend a good search path, etc.
  100. *
  101. * A recommended order for the search path is the write dir, then the base dir,
  102. * then the cdrom dir, then any archives discovered. Quake 3 does something
  103. * like this, but moves the archives to the start of the search path. Build
  104. * Engine games, like Duke Nukem 3D and Blood, place the archives last, and
  105. * use the base dir for both searching and writing. There is a helper
  106. * function (PHYSFS_setSaneConfig()) that puts together a basic configuration
  107. * for you, based on a few parameters. Also see the comments on
  108. * PHYSFS_getBaseDir(), and PHYSFS_getUserDir() for info on what those
  109. * are and how they can help you determine an optimal search path.
  110. *
  111. * PhysicsFS is mostly thread safe. The error messages returned by
  112. * PHYSFS_getLastError are unique by thread, and library-state-setting
  113. * functions are mutex'd. For efficiency, individual file accesses are
  114. * not locked, so you can not safely read/write/seek/close/etc the same
  115. * file from two threads at the same time. Other race conditions are bugs
  116. * that should be reported/patched.
  117. *
  118. * While you CAN use stdio/syscall file access in a program that has PHYSFS_*
  119. * calls, doing so is not recommended, and you can not use system
  120. * filehandles with PhysicsFS and vice versa.
  121. *
  122. * Note that archives need not be named as such: if you have a ZIP file and
  123. * rename it with a .PKG extension, the file will still be recognized as a
  124. * ZIP archive by PhysicsFS; the file's contents are used to determine its
  125. * type.
  126. *
  127. * Currently supported archive types:
  128. * - .ZIP (pkZip/WinZip/Info-ZIP compatible)
  129. * - .GRP (Build Engine groupfile archives)
  130. *
  131. * Please see the file LICENSE in the source's root directory for licensing
  132. * and redistribution rights.
  133. *
  134. * Please see the file CREDITS in the source's root directory for a complete
  135. * list of who's responsible for this.
  136. *
  137. * \author Ryan C. Gordon.
  138. */
  139. #ifndef _INCLUDE_PHYSFS_H_
  140. #define _INCLUDE_PHYSFS_H_
  141. #ifdef __cplusplus
  142. extern "C" {
  143. #endif
  144. #ifndef DOXYGEN_SHOULD_IGNORE_THIS
  145. #if (defined _MSC_VER)
  146. #define __EXPORT__ __declspec(dllexport)
  147. #else
  148. #define __EXPORT__
  149. #endif
  150. #endif /* DOXYGEN_SHOULD_IGNORE_THIS */
  151. /**
  152. * \typedef PHYSFS_uint8
  153. * \brief An unsigned, 8-bit integer type.
  154. */
  155. typedef unsigned char PHYSFS_uint8;
  156. /**
  157. * \typedef PHYSFS_sint8
  158. * \brief A signed, 8-bit integer type.
  159. */
  160. typedef signed char PHYSFS_sint8;
  161. /**
  162. * \typedef PHYSFS_uint16
  163. * \brief An unsigned, 16-bit integer type.
  164. */
  165. typedef unsigned short PHYSFS_uint16;
  166. /**
  167. * \typedef PHYSFS_sint16
  168. * \brief A signed, 16-bit integer type.
  169. */
  170. typedef signed short PHYSFS_sint16;
  171. /**
  172. * \typedef PHYSFS_uint32
  173. * \brief An unsigned, 32-bit integer type.
  174. */
  175. typedef unsigned int PHYSFS_uint32;
  176. /**
  177. * \typedef PHYSFS_sint32
  178. * \brief A signed, 32-bit integer type.
  179. */
  180. typedef signed int PHYSFS_sint32;
  181. /**
  182. * \typedef PHYSFS_uint64
  183. * \brief An unsigned, 64-bit integer type.
  184. * \warning on platforms without any sort of 64-bit datatype, this is
  185. * equivalent to PHYSFS_uint32!
  186. */
  187. /**
  188. * \typedef PHYSFS_sint64
  189. * \brief A signed, 64-bit integer type.
  190. * \warning on platforms without any sort of 64-bit datatype, this is
  191. * equivalent to PHYSFS_sint32!
  192. */
  193. #if (defined PHYSFS_NO_64BIT_SUPPORT) /* oh well. */
  194. typedef PHYSFS_uint32 PHYSFS_uint64;
  195. typedef PHYSFS_sint32 PHYSFS_sint64;
  196. #elif (defined _MSC_VER)
  197. typedef signed __int64 PHYSFS_sint64;
  198. typedef unsigned __int64 PHYSFS_uint64;
  199. #else
  200. typedef unsigned long long PHYSFS_uint64;
  201. typedef signed long long PHYSFS_sint64;
  202. #endif
  203. #ifndef DOXYGEN_SHOULD_IGNORE_THIS
  204. /* Make sure the types really have the right sizes */
  205. #define PHYSFS_COMPILE_TIME_ASSERT(name, x) \
  206. typedef int PHYSFS_dummy_ ## name[(x) * 2 - 1]
  207. PHYSFS_COMPILE_TIME_ASSERT(uint8, sizeof(PHYSFS_uint8) == 1);
  208. PHYSFS_COMPILE_TIME_ASSERT(sint8, sizeof(PHYSFS_sint8) == 1);
  209. PHYSFS_COMPILE_TIME_ASSERT(uint16, sizeof(PHYSFS_uint16) == 2);
  210. PHYSFS_COMPILE_TIME_ASSERT(sint16, sizeof(PHYSFS_sint16) == 2);
  211. PHYSFS_COMPILE_TIME_ASSERT(uint32, sizeof(PHYSFS_uint32) == 4);
  212. PHYSFS_COMPILE_TIME_ASSERT(sint32, sizeof(PHYSFS_sint32) == 4);
  213. #ifndef PHYSFS_NO_64BIT_SUPPORT
  214. PHYSFS_COMPILE_TIME_ASSERT(uint64, sizeof(PHYSFS_uint64) == 8);
  215. PHYSFS_COMPILE_TIME_ASSERT(sint64, sizeof(PHYSFS_sint64) == 8);
  216. #endif
  217. #undef PHYSFS_COMPILE_TIME_ASSERT
  218. #endif /* DOXYGEN_SHOULD_IGNORE_THIS */
  219. /**
  220. * \struct PHYSFS_file
  221. * \brief A PhysicsFS file handle.
  222. *
  223. * You get a pointer to one of these when you open a file for reading,
  224. * writing, or appending via PhysicsFS.
  225. *
  226. * As you can see from the lack of meaningful fields, you should treat this
  227. * as opaque data. Don't try to manipulate the file handle, just pass the
  228. * pointer you got, unmolested, to various PhysicsFS APIs.
  229. *
  230. * \sa PHYSFS_openRead
  231. * \sa PHYSFS_openWrite
  232. * \sa PHYSFS_openAppend
  233. * \sa PHYSFS_close
  234. * \sa PHYSFS_read
  235. * \sa PHYSFS_write
  236. * \sa PHYSFS_seek
  237. * \sa PHYSFS_tell
  238. * \sa PHYSFS_eof
  239. * \sa PHYSFS_setBuffer
  240. * \sa PHYSFS_flush
  241. */
  242. typedef struct
  243. {
  244. void *opaque; /**< That's all you get. Don't touch. */
  245. } PHYSFS_file;
  246. /**
  247. * \struct PHYSFS_ArchiveInfo
  248. * \brief Information on various PhysicsFS-supported archives.
  249. *
  250. * This structure gives you details on what sort of archives are supported
  251. * by this implementation of PhysicsFS. Archives tend to be things like
  252. * ZIP files and such.
  253. *
  254. * \warning Not all binaries are created equal! PhysicsFS can be built with
  255. * or without support for various archives. You can check with
  256. * PHYSFS_supportedArchiveTypes() to see if your archive type is
  257. * supported.
  258. *
  259. * \sa PHYSFS_supportedArchiveTypes
  260. */
  261. typedef struct
  262. {
  263. const char *extension; /**< Archive file extension: "ZIP", for example. */
  264. const char *description; /**< Human-readable archive description. */
  265. const char *author; /**< Person who did support for this archive. */
  266. const char *url; /**< URL related to this archive */
  267. } PHYSFS_ArchiveInfo;
  268. /**
  269. * \struct PHYSFS_Version
  270. * \brief Information the version of PhysicsFS in use.
  271. *
  272. * Represents the library's version as three levels: major revision
  273. * (increments with massive changes, additions, and enhancements),
  274. * minor revision (increments with backwards-compatible changes to the
  275. * major revision), and patchlevel (increments with fixes to the minor
  276. * revision).
  277. *
  278. * \sa PHYSFS_VERSION
  279. * \sa PHYFS_getLinkedVersion
  280. */
  281. typedef struct
  282. {
  283. PHYSFS_uint8 major; /**< major revision */
  284. PHYSFS_uint8 minor; /**< minor revision */
  285. PHYSFS_uint8 patch; /**< patchlevel */
  286. } PHYSFS_Version;
  287. #ifndef DOXYGEN_SHOULD_IGNORE_THIS
  288. #define PHYSFS_VER_MAJOR 0
  289. #define PHYSFS_VER_MINOR 1
  290. #define PHYSFS_VER_PATCH 8
  291. #endif /* DOXYGEN_SHOULD_IGNORE_THIS */
  292. /* PhysicsFS state stuff ... */
  293. /**
  294. * \def PHYSFS_VERSION(x)
  295. * \brief Macro to determine PhysicsFS version program was compiled against.
  296. *
  297. * This macro fills in a PHYSFS_Version structure with the version of the
  298. * library you compiled against. This is determined by what header the
  299. * compiler uses. Note that if you dynamically linked the library, you might
  300. * have a slightly newer or older version at runtime. That version can be
  301. * determined with PHYSFS_getLinkedVersion(), which, unlike PHYSFS_VERSION,
  302. * is not a macro.
  303. *
  304. * \param x A pointer to a PHYSFS_Version struct to initialize.
  305. *
  306. * \sa PHYSFS_Version
  307. * \sa PHYSFS_getLinkedVersion
  308. */
  309. #define PHYSFS_VERSION(x) \
  310. { \
  311. (x)->major = PHYSFS_VER_MAJOR; \
  312. (x)->minor = PHYSFS_VER_MINOR; \
  313. (x)->patch = PHYSFS_VER_PATCH; \
  314. }
  315. /**
  316. * \fn void PHYSFS_getLinkedVersion(PHYSFS_Version *ver)
  317. * \brief Get the version of PhysicsFS that is linked against your program.
  318. *
  319. * If you are using a shared library (DLL) version of PhysFS, then it is
  320. * possible that it will be different than the version you compiled against.
  321. *
  322. * This is a real function; the macro PHYSFS_VERSION tells you what version
  323. * of PhysFS you compiled against:
  324. *
  325. * \code
  326. * PHYSFS_Version compiled;
  327. * PHYSFS_Version linked;
  328. *
  329. * PHYSFS_VERSION(&compiled);
  330. * PHYSFS_getLinkedVersion(&linked);
  331. * printf("We compiled against PhysFS version %d.%d.%d ...\n",
  332. * compiled.major, compiled.minor, compiled.patch);
  333. * printf("But we linked against PhysFS version %d.%d.%d.\n",
  334. * linked.major, linked.minor, linked.patch);
  335. * \endcode
  336. *
  337. * This function may be called safely at any time, even before PHYSFS_init().
  338. *
  339. * \sa PHYSFS_VERSION
  340. */
  341. __EXPORT__ void PHYSFS_getLinkedVersion(PHYSFS_Version *ver);
  342. /**
  343. * \fn int PHYSFS_init(const char *argv0)
  344. * \brief Initialize the PhysicsFS library.
  345. *
  346. * This must be called before any other PhysicsFS function.
  347. *
  348. * This should be called prior to any attempts to change your process's
  349. * current working directory.
  350. *
  351. * \param argv0 the argv[0] string passed to your program's mainline.
  352. * This may be NULL on most platforms (such as ones without a
  353. * standard main() function), but you should always try to pass
  354. * something in here. Unix-like systems such as Linux _need_ to
  355. * pass argv[0] from main() in here.
  356. * \return nonzero on success, zero on error. Specifics of the error can be
  357. * gleaned from PHYSFS_getLastError().
  358. *
  359. * \sa PHYSFS_deinit
  360. */
  361. __EXPORT__ int PHYSFS_init(const char *argv0);
  362. /**
  363. * \fn int PHYSFS_deinit(void)
  364. * \brief Deinitialize the PhysicsFS library.
  365. *
  366. * This closes any files opened via PhysicsFS, blanks the search/write paths,
  367. * frees memory, and invalidates all of your file handles.
  368. *
  369. * Note that this call can FAIL if there's a file open for writing that
  370. * refuses to close (for example, the underlying operating system was
  371. * buffering writes to network filesystem, and the fileserver has crashed,
  372. * or a hard drive has failed, etc). It is usually best to close all write
  373. * handles yourself before calling this function, so that you can gracefully
  374. * handle a specific failure.
  375. *
  376. * Once successfully deinitialized, PHYSFS_init() can be called again to
  377. * restart the subsystem. All defaults API states are restored at this
  378. * point.
  379. *
  380. * \return nonzero on success, zero on error. Specifics of the error can be
  381. * gleaned from PHYSFS_getLastError(). If failure, state of PhysFS is
  382. * undefined, and probably badly screwed up.
  383. *
  384. * \sa PHYSFS_init
  385. */
  386. __EXPORT__ int PHYSFS_deinit(void);
  387. /**
  388. * \fn const PHYSFS_ArchiveInfo **PHYSFS_supportedArchiveTypes(void)
  389. * \brief Get a list of supported archive types.
  390. *
  391. * Get a list of archive types supported by this implementation of PhysicFS.
  392. * These are the file formats usable for search path entries. This is for
  393. * informational purposes only. Note that the extension listed is merely
  394. * convention: if we list "ZIP", you can open a PkZip-compatible archive
  395. * with an extension of "XYZ", if you like.
  396. *
  397. * The returned value is an array of pointers to PHYSFS_ArchiveInfo structures,
  398. * with a NULL entry to signify the end of the list:
  399. *
  400. * \code
  401. * PHYSFS_ArchiveInfo **i;
  402. *
  403. * for (i = PHYSFS_supportedArchiveTypes(); *i != NULL; i++)
  404. * {
  405. * printf("Supported archive: [%s], which is [%s].\n",
  406. * i->extension, i->description);
  407. * }
  408. * \endcode
  409. *
  410. * The return values are pointers to static internal memory, and should
  411. * be considered READ ONLY, and never freed.
  412. *
  413. * \return READ ONLY Null-terminated array of READ ONLY structures.
  414. */
  415. __EXPORT__ const PHYSFS_ArchiveInfo **PHYSFS_supportedArchiveTypes(void);
  416. /**
  417. * \fn void PHYSFS_freeList(void *listVar)
  418. * \brief Deallocate resources of lists returned by PhysicsFS.
  419. *
  420. * Certain PhysicsFS functions return lists of information that are
  421. * dynamically allocated. Use this function to free those resources.
  422. *
  423. * \param listVar List of information specified as freeable by this function.
  424. *
  425. * \sa PHYSFS_getCdRomDirs
  426. * \sa PHYSFS_enumerateFiles
  427. * \sa PHYSFS_getSearchPath
  428. */
  429. __EXPORT__ void PHYSFS_freeList(void *listVar);
  430. /**
  431. * \fn const char *PHYSFS_getLastError(void)
  432. * \brief Get human-readable error information.
  433. *
  434. * Get the last PhysicsFS error message as a null-terminated string.
  435. * This will be NULL if there's been no error since the last call to this
  436. * function. The pointer returned by this call points to an internal buffer.
  437. * Each thread has a unique error state associated with it, but each time
  438. * a new error message is set, it will overwrite the previous one associated
  439. * with that thread. It is safe to call this function at anytime, even
  440. * before PHYSFS_init().
  441. *
  442. * \return READ ONLY string of last error message.
  443. */
  444. __EXPORT__ const char *PHYSFS_getLastError(void);
  445. /**
  446. * \fn const char *PHYSFS_getDirSeparator(void)
  447. * \brief Get platform-dependent dir separator string.
  448. *
  449. * This returns "\\\\" on win32, "/" on Unix, and ":" on MacOS. It may be more
  450. * than one character, depending on the platform, and your code should take
  451. * that into account. Note that this is only useful for setting up the
  452. * search/write paths, since access into those dirs always use '/'
  453. * (platform-independent notation) to separate directories. This is also
  454. * handy for getting platform-independent access when using stdio calls.
  455. *
  456. * \return READ ONLY null-terminated string of platform's dir separator.
  457. */
  458. __EXPORT__ const char *PHYSFS_getDirSeparator(void);
  459. /**
  460. * \fn void PHYSFS_permitSymbolicLinks(int allow)
  461. * \brief Enable or disable following of symbolic links.
  462. *
  463. * Some physical filesystems and archives contain files that are just pointers
  464. * to other files. On the physical filesystem, opening such a link will
  465. * (transparently) open the file that is pointed to.
  466. *
  467. * By default, PhysicsFS will check if a file is really a symlink during open
  468. * calls and fail if it is. Otherwise, the link could take you outside the
  469. * write and search paths, and compromise security.
  470. *
  471. * If you want to take that risk, call this function with a non-zero parameter.
  472. * Note that this is more for sandboxing a program's scripting language, in
  473. * case untrusted scripts try to compromise the system. Generally speaking,
  474. * a user could very well have a legitimate reason to set up a symlink, so
  475. * unless you feel there's a specific danger in allowing them, you should
  476. * permit them.
  477. *
  478. * Symlinks are only explicitly checked when dealing with filenames
  479. * in platform-independent notation. That is, when setting up your
  480. * search and write paths, etc, symlinks are never checked for.
  481. *
  482. * Symbolic link permission can be enabled or disabled at any time after
  483. * you've called PHYSFS_init(), and is disabled by default.
  484. *
  485. * \param allow nonzero to permit symlinks, zero to deny linking.
  486. */
  487. __EXPORT__ void PHYSFS_permitSymbolicLinks(int allow);
  488. /**
  489. * \fn char **PHYSFS_getCdRomDirs(void)
  490. * \brief Get an array of paths to available CD-ROM drives.
  491. *
  492. * The dirs returned are platform-dependent ("D:\" on Win32, "/cdrom" or
  493. * whatnot on Unix). Dirs are only returned if there is a disc ready and
  494. * accessible in the drive. So if you've got two drives (D: and E:), and only
  495. * E: has a disc in it, then that's all you get. If the user inserts a disc
  496. * in D: and you call this function again, you get both drives. If, on a
  497. * Unix box, the user unmounts a disc and remounts it elsewhere, the next
  498. * call to this function will reflect that change. Fun.
  499. *
  500. * The returned value is an array of strings, with a NULL entry to signify the
  501. * end of the list:
  502. *
  503. * \code
  504. * char **cds = PHYSFS_getCdRomDirs();
  505. * char **i;
  506. *
  507. * for (i = cds; *i != NULL; i++)
  508. * printf("cdrom dir [%s] is available.\n", *i);
  509. *
  510. * PHYSFS_freeList(cds);
  511. * \endcode
  512. *
  513. * This call may block while drives spin up. Be forewarned.
  514. *
  515. * When you are done with the returned information, you may dispose of the
  516. * resources by calling PHYSFS_freeList() with the returned pointer.
  517. *
  518. * \return Null-terminated array of null-terminated strings.
  519. */
  520. __EXPORT__ char **PHYSFS_getCdRomDirs(void);
  521. /**
  522. * \fn const char *PHYSFS_getBaseDir(void)
  523. * \brief Get the path where the application resides.
  524. *
  525. * Helper function.
  526. *
  527. * Get the "base dir". This is the directory where the application was run
  528. * from, which is probably the installation directory, and may or may not
  529. * be the process's current working directory.
  530. *
  531. * You should probably use the base dir in your search path.
  532. *
  533. * \return READ ONLY string of base dir in platform-dependent notation.
  534. *
  535. * \sa PHYSFS_getUserDir
  536. */
  537. __EXPORT__ const char *PHYSFS_getBaseDir(void);
  538. /**
  539. * \fn const char *PHYSFS_getUserDir(void)
  540. * \brief Get the path where user's home directory resides.
  541. *
  542. * Helper function.
  543. *
  544. * Get the "user dir". This is meant to be a suggestion of where a specific
  545. * user of the system can store files. On Unix, this is her home directory.
  546. * On systems with no concept of multiple home directories (MacOS, win95),
  547. * this will default to something like "C:\mybasedir\users\username"
  548. * where "username" will either be the login name, or "default" if the
  549. * platform doesn't support multiple users, either.
  550. *
  551. * You should probably use the user dir as the basis for your write dir, and
  552. * also put it near the beginning of your search path.
  553. *
  554. * \return READ ONLY string of user dir in platform-dependent notation.
  555. *
  556. * \sa PHYSFS_getBaseDir
  557. */
  558. __EXPORT__ const char *PHYSFS_getUserDir(void);
  559. /**
  560. * \fn const char *PHYSFS_getWriteDir(void)
  561. * \brief Get path where PhysicsFS will allow file writing.
  562. *
  563. * Get the current write dir. The default write dir is NULL.
  564. *
  565. * \return READ ONLY string of write dir in platform-dependent notation,
  566. * OR NULL IF NO WRITE PATH IS CURRENTLY SET.
  567. *
  568. * \sa PHYSFS_setWriteDir
  569. */
  570. __EXPORT__ const char *PHYSFS_getWriteDir(void);
  571. /**
  572. * \fn int PHYSFS_setWriteDir(const char *newDir)
  573. * \brief Tell PhysicsFS where it may write files.
  574. *
  575. * Set a new write dir. This will override the previous setting. If the
  576. * directory or a parent directory doesn't exist in the physical filesystem,
  577. * PhysicsFS will attempt to create them as needed.
  578. *
  579. * This call will fail (and fail to change the write dir) if the current
  580. * write dir still has files open in it.
  581. *
  582. * \param newDir The new directory to be the root of the write dir,
  583. * specified in platform-dependent notation. Setting to NULL
  584. * disables the write dir, so no files can be opened for
  585. * writing via PhysicsFS.
  586. * \return non-zero on success, zero on failure. All attempts to open a file
  587. * for writing via PhysicsFS will fail until this call succeeds.
  588. * Specifics of the error can be gleaned from PHYSFS_getLastError().
  589. *
  590. * \sa PHYSFS_getWriteDir
  591. */
  592. __EXPORT__ int PHYSFS_setWriteDir(const char *newDir);
  593. /**
  594. * \fn int PHYSFS_addToSearchPath(const char *newDir, int appendToPath)
  595. * \brief Add an archive or directory to the search path.
  596. *
  597. * If this is a duplicate, the entry is not added again, even though the
  598. * function succeeds.
  599. *
  600. * \param newDir directory or archive to add to the path, in
  601. * platform-dependent notation.
  602. * \param appendToPath nonzero to append to search path, zero to prepend.
  603. * \return nonzero if added to path, zero on failure (bogus archive, dir
  604. * missing, etc). Specifics of the error can be
  605. * gleaned from PHYSFS_getLastError().
  606. *
  607. * \sa PHYSFS_removeFromSearchPath
  608. * \sa PHYSFS_getSearchPath
  609. */
  610. __EXPORT__ int PHYSFS_addToSearchPath(const char *newDir, int appendToPath);
  611. /**
  612. * \fn int PHYSFS_removeFromSearchPath(const char *oldDir)
  613. * \brief Remove a directory or archive from the search path.
  614. *
  615. * This must be a (case-sensitive) match to a dir or archive already in the
  616. * search path, specified in platform-dependent notation.
  617. *
  618. * This call will fail (and fail to remove from the path) if the element still
  619. * has files open in it.
  620. *
  621. * \param oldDir dir/archive to remove.
  622. * \return nonzero on success, zero on failure.
  623. * Specifics of the error can be gleaned from PHYSFS_getLastError().
  624. *
  625. * \sa PHYSFS_addToSearchPath
  626. * \sa PHYSFS_getSearchPath
  627. */
  628. __EXPORT__ int PHYSFS_removeFromSearchPath(const char *oldDir);
  629. /**
  630. * \fn char **PHYSFS_getSearchPath(void)
  631. * \brief Get the current search path.
  632. *
  633. * The default search path is an empty list.
  634. *
  635. * The returned value is an array of strings, with a NULL entry to signify the
  636. * end of the list:
  637. *
  638. * \code
  639. * char **i;
  640. *
  641. * for (i = PHYSFS_getSearchPath(); *i != NULL; i++)
  642. * printf("[%s] is in the search path.\n", *i);
  643. * \endcode
  644. *
  645. * When you are done with the returned information, you may dispose of the
  646. * resources by calling PHYSFS_freeList() with the returned pointer.
  647. *
  648. * \return Null-terminated array of null-terminated strings. NULL if there
  649. * was a problem (read: OUT OF MEMORY).
  650. *
  651. * \sa PHYSFS_addToSearchPath
  652. * \sa PHYSFS_removeFromSearchPath
  653. */
  654. __EXPORT__ char **PHYSFS_getSearchPath(void);
  655. /**
  656. * \fn int PHYSFS_setSaneConfig(const char *organization, const char *appName, const char *archiveExt, int includeCdRoms, int archivesFirst)
  657. * \brief Set up sane, default paths.
  658. *
  659. * Helper function.
  660. *
  661. * The write dir will be set to "userdir/.organization/appName", which is
  662. * created if it doesn't exist.
  663. *
  664. * The above is sufficient to make sure your program's configuration directory
  665. * is separated from other clutter, and platform-independent. The period
  666. * before "mygame" even hides the directory on Unix systems.
  667. *
  668. * The search path will be:
  669. *
  670. * - The Write Dir (created if it doesn't exist)
  671. * - The Base Dir (PHYSFS_getBaseDir())
  672. * - All found CD-ROM dirs (optionally)
  673. *
  674. * These directories are then searched for files ending with the extension
  675. * (archiveExt), which, if they are valid and supported archives, will also
  676. * be added to the search path. If you specified "PKG" for (archiveExt), and
  677. * there's a file named data.PKG in the base dir, it'll be checked. Archives
  678. * can either be appended or prepended to the search path in alphabetical
  679. * order, regardless of which directories they were found in.
  680. *
  681. * All of this can be accomplished from the application, but this just does it
  682. * all for you. Feel free to add more to the search path manually, too.
  683. *
  684. * \param organization Name of your company/group/etc to be used as a
  685. * dirname, so keep it small, and no-frills.
  686. *
  687. * \param appName Program-specific name of your program, to separate it
  688. * from other programs using PhysicsFS.
  689. *
  690. * \param archiveExt File extension used by your program to specify an
  691. * archive. For example, Quake 3 uses "pk3", even though
  692. * they are just zipfiles. Specify NULL to not dig out
  693. * archives automatically. Do not specify the '.' char;
  694. * If you want to look for ZIP files, specify "ZIP" and
  695. * not ".ZIP" ... the archive search is case-insensitive.
  696. *
  697. * \param includeCdRoms Non-zero to include CD-ROMs in the search path, and
  698. * (if (archiveExt) != NULL) search them for archives.
  699. * This may cause a significant amount of blocking
  700. * while discs are accessed, and if there are no discs
  701. * in the drive (or even not mounted on Unix systems),
  702. * then they may not be made available anyhow. You may
  703. * want to specify zero and handle the disc setup
  704. * yourself.
  705. *
  706. * \param archivesFirst Non-zero to prepend the archives to the search path.
  707. * Zero to append them. Ignored if !(archiveExt).
  708. *
  709. * \return nonzero on success, zero on error. Specifics of the error can be
  710. * gleaned from PHYSFS_getLastError().
  711. */
  712. __EXPORT__ int PHYSFS_setSaneConfig(const char *organization,
  713. const char *appName,
  714. const char *archiveExt,
  715. int includeCdRoms,
  716. int archivesFirst);
  717. /* Directory management stuff ... */
  718. /**
  719. * \fn int PHYSFS_mkdir(const char *dirName)
  720. * \brief Create a directory.
  721. *
  722. * This is specified in platform-independent notation in relation to the
  723. * write dir. All missing parent directories are also created if they
  724. * don't exist.
  725. *
  726. * So if you've got the write dir set to "C:\mygame\writedir" and call
  727. * PHYSFS_mkdir("downloads/maps") then the directories
  728. * "C:\mygame\writedir\downloads" and "C:\mygame\writedir\downloads\maps"
  729. * will be created if possible. If the creation of "maps" fails after we
  730. * have successfully created "downloads", then the function leaves the
  731. * created directory behind and reports failure.
  732. *
  733. * \param dirName New dir to create.
  734. * \return nonzero on success, zero on error. Specifics of the error can be
  735. * gleaned from PHYSFS_getLastError().
  736. *
  737. * \sa PHYSFS_delete
  738. */
  739. __EXPORT__ int PHYSFS_mkdir(const char *dirName);
  740. /**
  741. * \fn int PHYSFS_delete(const char *filename)
  742. * \brief Delete a file or directory.
  743. *
  744. * (filename) is specified in platform-independent notation in relation to the
  745. * write dir.
  746. *
  747. * A directory must be empty before this call can delete it.
  748. *
  749. * Deleting a symlink will remove the link, not what it points to, regardless
  750. * of whether you "permitSymLinks" or not.
  751. *
  752. * So if you've got the write dir set to "C:\mygame\writedir" and call
  753. * PHYSFS_delete("downloads/maps/level1.map") then the file
  754. * "C:\mygame\writedir\downloads\maps\level1.map" is removed from the
  755. * physical filesystem, if it exists and the operating system permits the
  756. * deletion.
  757. *
  758. * Note that on Unix systems, deleting a file may be successful, but the
  759. * actual file won't be removed until all processes that have an open
  760. * filehandle to it (including your program) close their handles.
  761. *
  762. * Chances are, the bits that make up the file still exist, they are just
  763. * made available to be written over at a later point. Don't consider this
  764. * a security method or anything. :)
  765. *
  766. * \param filename Filename to delete.
  767. * \return nonzero on success, zero on error. Specifics of the error can be
  768. * gleaned from PHYSFS_getLastError().
  769. */
  770. __EXPORT__ int PHYSFS_delete(const char *filename);
  771. /**
  772. * \fn const char *PHYSFS_getRealDir(const char *filename)
  773. * \brief Figure out where in the search path a file resides.
  774. *
  775. * The file is specified in platform-independent notation. The returned
  776. * filename will be the element of the search path where the file was found,
  777. * which may be a directory, or an archive. Even if there are multiple
  778. * matches in different parts of the search path, only the first one found
  779. * is used, just like when opening a file.
  780. *
  781. * So, if you look for "maps/level1.map", and C:\mygame is in your search
  782. * path and C:\mygame\maps\level1.map exists, then "C:\mygame" is returned.
  783. *
  784. * If a any part of a match is a symbolic link, and you've not explicitly
  785. * permitted symlinks, then it will be ignored, and the search for a match
  786. * will continue.
  787. *
  788. * \param filename file to look for.
  789. * \return READ ONLY string of element of search path containing the
  790. * the file in question. NULL if not found.
  791. */
  792. __EXPORT__ const char *PHYSFS_getRealDir(const char *filename);
  793. /**
  794. * \fn char **PHYSFS_enumerateFiles(const char *dir)
  795. * \brief Get a file listing of a search path's directory.
  796. *
  797. * Matching directories are interpolated. That is, if "C:\mydir" is in the
  798. * search path and contains a directory "savegames" that contains "x.sav",
  799. * "y.sav", and "z.sav", and there is also a "C:\userdir" in the search path
  800. * that has a "savegames" subdirectory with "w.sav", then the following code:
  801. *
  802. * \code
  803. * char **rc = PHYSFS_enumerateFiles("savegames");
  804. * char **i;
  805. *
  806. * for (i = rc; *i != NULL; i++)
  807. * printf(" * We've got [%s].\n", *i);
  808. *
  809. * PHYSFS_freeList(rc);
  810. * \endcode
  811. *
  812. * ...will print:
  813. *
  814. * \verbatim
  815. * We've got [x.sav].
  816. * We've got [y.sav].
  817. * We've got [z.sav].
  818. * We've got [w.sav].\endverbatim
  819. *
  820. * Feel free to sort the list however you like. We only promise there will
  821. * be no duplicates, but not what order the final list will come back in.
  822. *
  823. * Don't forget to call PHYSFS_freeList() with the return value from this
  824. * function when you are done with it.
  825. *
  826. * \param dir directory in platform-independent notation to enumerate.
  827. * \return Null-terminated array of null-terminated strings.
  828. */
  829. __EXPORT__ char **PHYSFS_enumerateFiles(const char *dir);
  830. /**
  831. * \fn int PHYSFS_exists(const char *fname)
  832. * \brief Determine if a file exists in the search path.
  833. *
  834. * Reports true if there is an entry anywhere in the search path by the
  835. * name of (fname).
  836. *
  837. * Note that entries that are symlinks are ignored if
  838. * PHYSFS_permitSymbolicLinks(1) hasn't been called, so you
  839. * might end up further down in the search path than expected.
  840. *
  841. * \param fname filename in platform-independent notation.
  842. * \return non-zero if filename exists. zero otherwise.
  843. *
  844. * \sa PHYSFS_isDirectory
  845. * \sa PHYSFS_isSymbolicLink
  846. */
  847. __EXPORT__ int PHYSFS_exists(const char *fname);
  848. /**
  849. * \fn int PHYSFS_isDirectory(const char *fname)
  850. * \brief Determine if a file in the search path is really a directory.
  851. *
  852. * Determine if the first occurence of (fname) in the search path is
  853. * really a directory entry.
  854. *
  855. * Note that entries that are symlinks are ignored if
  856. * PHYSFS_permitSymbolicLinks(1) hasn't been called, so you
  857. * might end up further down in the search path than expected.
  858. *
  859. * \param fname filename in platform-independent notation.
  860. * \return non-zero if filename exists and is a directory. zero otherwise.
  861. *
  862. * \sa PHYSFS_exists
  863. * \sa PHYSFS_isSymbolicLink
  864. */
  865. __EXPORT__ int PHYSFS_isDirectory(const char *fname);
  866. /**
  867. * \fn int PHYSFS_isSymbolicLink(const char *fname)
  868. * \brief Determine if a file in the search path is really a symbolic link.
  869. *
  870. * Determine if the first occurence of (fname) in the search path is
  871. * really a symbolic link.
  872. *
  873. * Note that entries that are symlinks are ignored if
  874. * PHYSFS_permitSymbolicLinks(1) hasn't been called, and as such,
  875. * this function will always return 0 in that case.
  876. *
  877. * \param fname filename in platform-independent notation.
  878. * \return non-zero if filename exists and is a symlink. zero otherwise.
  879. *
  880. * \sa PHYSFS_exists
  881. * \sa PHYSFS_isDirectory
  882. */
  883. __EXPORT__ int PHYSFS_isSymbolicLink(const char *fname);
  884. /**
  885. * \fn PHYSFS_sint64 PHYSFS_getLastModTime(const char *filename)
  886. * \brief Get the last modification time of a file.
  887. *
  888. * The modtime is returned as a number of seconds since the epoch
  889. * (Jan 1, 1970). The exact derivation and accuracy of this time depends on
  890. * the particular archiver. If there is no reasonable way to obtain this
  891. * information for a particular archiver, or there was some sort of error,
  892. * this function returns (-1).
  893. *
  894. * \param filename filename to check, in platform-independent notation.
  895. * \return last modified time of the file. -1 if it can't be determined.
  896. */
  897. __EXPORT__ PHYSFS_sint64 PHYSFS_getLastModTime(const char *filename);
  898. /* i/o stuff... */
  899. /**
  900. * \fn PHYSFS_file *PHYSFS_openWrite(const char *filename)
  901. * \brief Open a file for writing.
  902. *
  903. * Open a file for writing, in platform-independent notation and in relation
  904. * to the write dir as the root of the writable filesystem. The specified
  905. * file is created if it doesn't exist. If it does exist, it is truncated to
  906. * zero bytes, and the writing offset is set to the start.
  907. *
  908. * Note that entries that are symlinks are ignored if
  909. * PHYSFS_permitSymbolicLinks(1) hasn't been called, and opening a
  910. * symlink with this function will fail in such a case.
  911. *
  912. * \param filename File to open.
  913. * \return A valid PhysicsFS filehandle on success, NULL on error. Specifics
  914. * of the error can be gleaned from PHYSFS_getLastError().
  915. *
  916. * \sa PHYSFS_openRead
  917. * \sa PHYSFS_openAppend
  918. * \sa PHYSFS_write
  919. * \sa PHYSFS_close
  920. */
  921. __EXPORT__ PHYSFS_file *PHYSFS_openWrite(const char *filename);
  922. /**
  923. * \fn PHYSFS_file *PHYSFS_openAppend(const char *filename)
  924. * \brief Open a file for appending.
  925. *
  926. * Open a file for writing, in platform-independent notation and in relation
  927. * to the write dir as the root of the writable filesystem. The specified
  928. * file is created if it doesn't exist. If it does exist, the writing offset
  929. * is set to the end of the file, so the first write will be the byte after
  930. * the end.
  931. *
  932. * Note that entries that are symlinks are ignored if
  933. * PHYSFS_permitSymbolicLinks(1) hasn't been called, and opening a
  934. * symlink with this function will fail in such a case.
  935. *
  936. * \param filename File to open.
  937. * \return A valid PhysicsFS filehandle on success, NULL on error. Specifics
  938. * of the error can be gleaned from PHYSFS_getLastError().
  939. *
  940. * \sa PHYSFS_openRead
  941. * \sa PHYSFS_openWrite
  942. * \sa PHYSFS_write
  943. * \sa PHYSFS_close
  944. */
  945. __EXPORT__ PHYSFS_file *PHYSFS_openAppend(const char *filename);
  946. /**
  947. * \fn PHYSFS_file *PHYSFS_openRead(const char *filename)
  948. * \brief Open a file for reading.
  949. *
  950. * Open a file for reading, in platform-independent notation. The search path
  951. * is checked one at a time until a matching file is found, in which case an
  952. * abstract filehandle is associated with it, and reading may be done.
  953. * The reading offset is set to the first byte of the file.
  954. *
  955. * Note that entries that are symlinks are ignored if
  956. * PHYSFS_permitSymbolicLinks(1) hasn't been called, and opening a
  957. * symlink with this function will fail in such a case.
  958. *
  959. * \param filename File to open.
  960. * \return A valid PhysicsFS filehandle on success, NULL on error. Specifics
  961. * of the error can be gleaned from PHYSFS_getLastError().
  962. *
  963. * \sa PHYSFS_openWrite
  964. * \sa PHYSFS_openAppend
  965. * \sa PHYSFS_read
  966. * \sa PHYSFS_close
  967. */
  968. __EXPORT__ PHYSFS_file *PHYSFS_openRead(const char *filename);
  969. /**
  970. * \fn int PHYSFS_close(PHYSFS_file *handle)
  971. * \brief Close a PhysicsFS filehandle.
  972. *
  973. * This call is capable of failing if the operating system was buffering
  974. * writes to the physical media, and, now forced to write those changes to
  975. * physical media, can not store the data for some reason. In such a case,
  976. * the filehandle stays open. A well-written program should ALWAYS check the
  977. * return value from the close call in addition to every writing call!
  978. *
  979. * \param handle handle returned from PHYSFS_open*().
  980. * \return nonzero on success, zero on error. Specifics of the error can be
  981. * gleaned from PHYSFS_getLastError().
  982. *
  983. * \sa PHYSFS_openRead
  984. * \sa PHYSFS_openWrite
  985. * \sa PHYSFS_openAppend
  986. */
  987. __EXPORT__ int PHYSFS_close(PHYSFS_file *handle);
  988. /**
  989. * \fn PHYSFS_sint64 PHYSFS_read(PHYSFS_file *handle, void *buffer, PHYSFS_uint32 objSize, PHYSFS_uint32 objCount)
  990. * \brief Read data from a PhysicsFS filehandle
  991. *
  992. * The file must be opened for reading.
  993. *
  994. * \param handle handle returned from PHYSFS_openRead().
  995. * \param buffer buffer to store read data into.
  996. * \param objSize size in bytes of objects being read from (handle).
  997. * \param objCount number of (objSize) objects to read from (handle).
  998. * \return number of objects read. PHYSFS_getLastError() can shed light on
  999. * the reason this might be < (objCount), as can PHYSFS_eof().
  1000. * -1 if complete failure.
  1001. *
  1002. * \sa PHYSFS_eof
  1003. */
  1004. __EXPORT__ PHYSFS_sint64 PHYSFS_read(PHYSFS_file *handle,
  1005. void *buffer,
  1006. PHYSFS_uint32 objSize,
  1007. PHYSFS_uint32 objCount);
  1008. /**
  1009. * \fn PHYSFS_sint64 PHYSFS_write(PHYSFS_file *handle, const void *buffer, PHYSFS_uint32 objSize, PHYSFS_uint32 objCount)
  1010. * \brief Write data to a PhysicsFS filehandle
  1011. *
  1012. * The file must be opened for writing.
  1013. *
  1014. * \param handle retval from PHYSFS_openWrite() or PHYSFS_openAppend().
  1015. * \param buffer buffer to store read data into.
  1016. * \param objSize size in bytes of objects being read from (handle).
  1017. * \param objCount number of (objSize) objects to read from (handle).
  1018. * \return number of objects written. PHYSFS_getLastError() can shed light on
  1019. * the reason this might be < (objCount). -1 if complete failure.
  1020. */
  1021. __EXPORT__ PHYSFS_sint64 PHYSFS_write(PHYSFS_file *handle,
  1022. const void *buffer,
  1023. PHYSFS_uint32 objSize,
  1024. PHYSFS_uint32 objCount);
  1025. /* File position stuff... */
  1026. /**
  1027. * \fn int PHYSFS_eof(PHYSFS_file *handle)
  1028. * \brief Check for end-of-file state on a PhysicsFS filehandle.
  1029. *
  1030. * Determine if the end of file has been reached in a PhysicsFS filehandle.
  1031. *
  1032. * \param handle handle returned from PHYSFS_openRead().
  1033. * \return nonzero if EOF, zero if not.
  1034. *
  1035. * \sa PHYSFS_read
  1036. * \sa PHYSFS_tell
  1037. */
  1038. __EXPORT__ int PHYSFS_eof(PHYSFS_file *handle);
  1039. /**
  1040. * \fn PHYSFS_sint64 PHYSFS_tell(PHYSFS_file *handle)
  1041. * \brief Determine current position within a PhysicsFS filehandle.
  1042. *
  1043. * \param handle handle returned from PHYSFS_open*().
  1044. * \return offset in bytes from start of file. -1 if error occurred.
  1045. * Specifics of the error can be gleaned from PHYSFS_getLastError().
  1046. *
  1047. * \sa PHYSFS_seek
  1048. */
  1049. __EXPORT__ PHYSFS_sint64 PHYSFS_tell(PHYSFS_file *handle);
  1050. /**
  1051. * \fn int PHYSFS_seek(PHYSFS_file *handle, PHYSFS_uint64 pos)
  1052. * \brief Seek to a new position within a PhysicsFS filehandle.
  1053. *
  1054. * The next read or write will occur at that place. Seeking past the
  1055. * beginning or end of the file is not allowed, and causes an error.
  1056. *
  1057. * \param handle handle returned from PHYSFS_open*().
  1058. * \param pos number of bytes from start of file to seek to.
  1059. * \return nonzero on success, zero on error. Specifics of the error can be
  1060. * gleaned from PHYSFS_getLastError().
  1061. *
  1062. * \sa PHYSFS_tell
  1063. */
  1064. __EXPORT__ int PHYSFS_seek(PHYSFS_file *handle, PHYSFS_uint64 pos);
  1065. /**
  1066. * \fn PHYSFS_sint64 PHYSFS_fileLength(PHYSFS_file *handle)
  1067. * \brief Get total length of a file in bytes.
  1068. *
  1069. * Note that if the file size can't be determined (since the archive is
  1070. * "streamed" or whatnot) than this will report (-1). Also note that if
  1071. * another process/thread is writing to this file at the same time, then
  1072. * the information this function supplies could be incorrect before you
  1073. * get it. Use with caution, or better yet, don't use at all.
  1074. *
  1075. * \param handle handle returned from PHYSFS_open*().
  1076. * \return size in bytes of the file. -1 if can't be determined.
  1077. *
  1078. * \sa PHYSFS_tell
  1079. * \sa PHYSFS_seek
  1080. */
  1081. __EXPORT__ PHYSFS_sint64 PHYSFS_fileLength(PHYSFS_file *handle);
  1082. /* Buffering stuff... */
  1083. /**
  1084. * \fn int PHYSFS_setBuffer(PHYSFS_file *handle, PHYSFS_uint64 bufsize)
  1085. * \brief Set up buffering for a PhysicsFS file handle.
  1086. *
  1087. * Define an i/o buffer for a file handle. A memory block of (bufsize) bytes
  1088. * will be allocated and associated with (handle).
  1089. *
  1090. * For files opened for reading, up to (bufsize) bytes are read from (handle)
  1091. * and stored in the internal buffer. Calls to PHYSFS_read() will pull
  1092. * from this buffer until it is empty, and then refill it for more reading.
  1093. * Note that compressed files, like ZIP archives, will decompress while
  1094. * buffering, so this can be handy for offsetting CPU-intensive operations.
  1095. * The buffer isn't filled until you do your next read.
  1096. *
  1097. * For files opened for writing, data will be buffered to memory until the
  1098. * buffer is full or the buffer is flushed. Closing a handle implicitly
  1099. * causes a flush...check your return values!
  1100. *
  1101. * Seeking, etc transparently accounts for buffering.
  1102. *
  1103. * You can resize an existing buffer by calling this function more than once
  1104. * on the same file. Setting the buffer size to zero will free an existing
  1105. * buffer.
  1106. *
  1107. * PhysicsFS file handles are unbuffered by default.
  1108. *
  1109. * Please check the return value of this function! Failures can include
  1110. * not being able to seek backwards in a read-only file when removing the
  1111. * buffer, not being able to allocate the buffer, and not being able to
  1112. * flush the buffer to disk, among other unexpected problems.
  1113. *
  1114. * \param handle handle returned from PHYSFS_open*().
  1115. * \param bufsize size, in bytes, of buffer to allocate.
  1116. * \return nonzero if successful, zero on error.
  1117. *
  1118. * \sa PHYSFS_flush
  1119. * \sa PHYSFS_read
  1120. * \sa PHYSFS_write
  1121. * \sa PHYSFS_close
  1122. */
  1123. __EXPORT__ int PHYSFS_setBuffer(PHYSFS_file *handle, PHYSFS_uint64 bufsize);
  1124. /**
  1125. * \fn int PHYSFS_flush(PHYSFS_file *handle)
  1126. * \brief Flush a buffered PhysicsFS file handle.
  1127. *
  1128. * For buffered files opened for writing, this will put the current contents
  1129. * of the buffer to disk and flag the buffer as empty if possible.
  1130. *
  1131. * For buffered files opened for reading or unbuffered files, this is a safe
  1132. * no-op, and will report success.
  1133. *
  1134. * \param handle handle returned from PHYSFS_open*().
  1135. * \return nonzero if successful, zero on error.
  1136. *
  1137. * \sa PHYSFS_setBuffer
  1138. * \sa PHYSFS_close
  1139. */
  1140. __EXPORT__ int PHYSFS_flush(PHYSFS_file *handle);
  1141. /* Byteorder stuff... */
  1142. /**
  1143. * \fn PHYSFS_sint16 PHYSFS_swapSLE16(PHYSFS_sint16 val)
  1144. * \brief Swap littleendian signed 16 to platform's native byte order.
  1145. *
  1146. * Take a 16-bit signed value in littleendian format and convert it to
  1147. * the platform's native byte order.
  1148. *
  1149. * \param val value to convert
  1150. * \return converted value.
  1151. */
  1152. __EXPORT__ PHYSFS_sint16 PHYSFS_swapSLE16(PHYSFS_sint16 val);
  1153. /**
  1154. * \fn PHYSFS_uint16 PHYSFS_swapULE16(PHYSFS_uint16 val)
  1155. * \brief Swap littleendian unsigned 16 to platform's native byte order.
  1156. *
  1157. * Take a 16-bit unsigned value in littleendian format and convert it to
  1158. * the platform's native byte order.
  1159. *
  1160. * \param val value to convert
  1161. * \return converted value.
  1162. */
  1163. __EXPORT__ PHYSFS_uint16 PHYSFS_swapULE16(PHYSFS_uint16 val);
  1164. /**
  1165. * \fn PHYSFS_sint32 PHYSFS_swapSLE32(PHYSFS_sint32 val)
  1166. * \brief Swap littleendian signed 32 to platform's native byte order.
  1167. *
  1168. * Take a 32-bit signed value in littleendian format and convert it to
  1169. * the platform's native byte order.
  1170. *
  1171. * \param val value to convert
  1172. * \return converted value.
  1173. */
  1174. __EXPORT__ PHYSFS_sint32 PHYSFS_swapSLE32(PHYSFS_sint32 val);
  1175. /**
  1176. * \fn PHYSFS_uint32 PHYSFS_swapULE32(PHYSFS_uint32 val)
  1177. * \brief Swap littleendian unsigned 32 to platform's native byte order.
  1178. *
  1179. * Take a 32-bit unsigned value in littleendian format and convert it to
  1180. * the platform's native byte order.
  1181. *
  1182. * \param val value to convert
  1183. * \return converted value.
  1184. */
  1185. __EXPORT__ PHYSFS_uint32 PHYSFS_swapULE32(PHYSFS_uint32 val);
  1186. /**
  1187. * \fn PHYSFS_sint64 PHYSFS_swapSLE64(PHYSFS_sint64 val)
  1188. * \brief Swap littleendian signed 64 to platform's native byte order.
  1189. *
  1190. * Take a 64-bit signed value in littleendian format and convert it to
  1191. * the platform's native byte order.
  1192. *
  1193. * \param val value to convert
  1194. * \return converted value.
  1195. *
  1196. * \warning Remember, PHYSFS_uint64 is only 32 bits on platforms without
  1197. * any sort of 64-bit support.
  1198. */
  1199. __EXPORT__ PHYSFS_sint64 PHYSFS_swapSLE64(PHYSFS_sint64 val);
  1200. /**
  1201. * \fn PHYSFS_uint64 PHYSFS_swapULE64(PHYSFS_uint64 val)
  1202. * \brief Swap littleendian unsigned 64 to platform's native byte order.
  1203. *
  1204. * Take a 64-bit unsigned value in littleendian format and convert it to
  1205. * the platform's native byte order.
  1206. *
  1207. * \param val value to convert
  1208. * \return converted value.
  1209. *
  1210. * \warning Remember, PHYSFS_uint64 is only 32 bits on platforms without
  1211. * any sort of 64-bit support.
  1212. */
  1213. __EXPORT__ PHYSFS_uint64 PHYSFS_swapULE64(PHYSFS_uint64 val);
  1214. /**
  1215. * \fn PHYSFS_sint16 PHYSFS_swapSBE16(PHYSFS_sint16 val)
  1216. * \brief Swap bigendian signed 16 to platform's native byte order.
  1217. *
  1218. * Take a 16-bit signed value in bigendian format and convert it to
  1219. * the platform's native byte order.
  1220. *
  1221. * \param val value to convert
  1222. * \return converted value.
  1223. */
  1224. __EXPORT__ PHYSFS_sint16 PHYSFS_swapSBE16(PHYSFS_sint16 val);
  1225. /**
  1226. * \fn PHYSFS_uint16 PHYSFS_swapUBE16(PHYSFS_uint16 val)
  1227. * \brief Swap bigendian unsigned 16 to platform's native byte order.
  1228. *
  1229. * Take a 16-bit unsigned value in bigendian format and convert it to
  1230. * the platform's native byte order.
  1231. *
  1232. * \param val value to convert
  1233. * \return converted value.
  1234. */
  1235. __EXPORT__ PHYSFS_uint16 PHYSFS_swapUBE16(PHYSFS_uint16 val);
  1236. /**
  1237. * \fn PHYSFS_sint32 PHYSFS_swapSBE32(PHYSFS_sint32 val)
  1238. * \brief Swap bigendian signed 32 to platform's native byte order.
  1239. *
  1240. * Take a 32-bit signed value in bigendian format and convert it to
  1241. * the platform's native byte order.
  1242. *
  1243. * \param val value to convert
  1244. * \return converted value.
  1245. */
  1246. __EXPORT__ PHYSFS_sint32 PHYSFS_swapSBE32(PHYSFS_sint32 val);
  1247. /**
  1248. * \fn PHYSFS_uint32 PHYSFS_swapUBE32(PHYSFS_uint32 val)
  1249. * \brief Swap bigendian unsigned 32 to platform's native byte order.
  1250. *
  1251. * Take a 32-bit unsigned value in bigendian format and convert it to
  1252. * the platform's native byte order.
  1253. *
  1254. * \param val value to convert
  1255. * \return converted value.
  1256. */
  1257. __EXPORT__ PHYSFS_uint32 PHYSFS_swapUBE32(PHYSFS_uint32 val);
  1258. /**
  1259. * \fn PHYSFS_sint64 PHYSFS_swapSBE64(PHYSFS_sint64 val)
  1260. * \brief Swap bigendian signed 64 to platform's native byte order.
  1261. *
  1262. * Take a 64-bit signed value in bigendian format and convert it to
  1263. * the platform's native byte order.
  1264. *
  1265. * \param val value to convert
  1266. * \return converted value.
  1267. *
  1268. * \warning Remember, PHYSFS_uint64 is only 32 bits on platforms without
  1269. * any sort of 64-bit support.
  1270. */
  1271. __EXPORT__ PHYSFS_sint64 PHYSFS_swapSBE64(PHYSFS_sint64 val);
  1272. /**
  1273. * \fn PHYSFS_uint64 PHYSFS_swapUBE64(PHYSFS_uint64 val)
  1274. * \brief Swap bigendian unsigned 64 to platform's native byte order.
  1275. *
  1276. * Take a 64-bit unsigned value in bigendian format and convert it to
  1277. * the platform's native byte order.
  1278. *
  1279. * \param val value to convert
  1280. * \return converted value.
  1281. *
  1282. * \warning Remember, PHYSFS_uint64 is only 32 bits on platforms without
  1283. * any sort of 64-bit support.
  1284. */
  1285. __EXPORT__ PHYSFS_uint64 PHYSFS_swapUBE64(PHYSFS_uint64 val);
  1286. /**
  1287. * \fn int PHYSFS_readSLE16(PHYSFS_file *file, PHYSFS_sint16 *val)
  1288. * \brief Read and convert a signed 16-bit littleendian value.
  1289. *
  1290. * Convenience function. Read a signed 16-bit littleendian value from a
  1291. * file and convert it to the platform's native byte order.
  1292. *
  1293. * \param file PhysicsFS file handle from which to read.
  1294. * \param val pointer to where value should be stored.
  1295. * \return zero on failure, non-zero on success. If successful, (*val) will
  1296. * store the result. On failure, you can find out what went wrong
  1297. * from PHYSFS_GetLastError().
  1298. */
  1299. __EXPORT__ int PHYSFS_readSLE16(PHYSFS_file *file, PHYSFS_sint16 *val);
  1300. /**
  1301. * \fn int PHYSFS_readULE16(PHYSFS_file *file, PHYSFS_uint16 *val)
  1302. * \brief Read and convert an unsigned 16-bit littleendian value.
  1303. *
  1304. * Convenience function. Read an unsigned 16-bit littleendian value from a
  1305. * file and convert it to the platform's native byte order.
  1306. *
  1307. * \param file PhysicsFS file handle from which to read.
  1308. * \param val pointer to where value should be stored.
  1309. * \return zero on failure, non-zero on success. If successful, (*val) will
  1310. * store the result. On failure, you can find out what went wrong
  1311. * from PHYSFS_GetLastError().
  1312. *
  1313. */
  1314. __EXPORT__ int PHYSFS_readULE16(PHYSFS_file *file, PHYSFS_uint16 *val);
  1315. /**
  1316. * \fn int PHYSFS_readSBE16(PHYSFS_file *file, PHYSFS_sint16 *val)
  1317. * \brief Read and convert a signed 16-bit bigendian value.
  1318. *
  1319. * Convenience function. Read a signed 16-bit bigendian value from a
  1320. * file and convert it to the platform's native byte order.
  1321. *
  1322. * \param file PhysicsFS file handle from which to read.
  1323. * \param val pointer to where value should be stored.
  1324. * \return zero on failure, non-zero on success. If successful, (*val) will
  1325. * store the result. On failure, you can find out what went wrong
  1326. * from PHYSFS_GetLastError().
  1327. */
  1328. __EXPORT__ int PHYSFS_readSBE16(PHYSFS_file *file, PHYSFS_sint16 *val);
  1329. /**
  1330. * \fn int PHYSFS_readUBE16(PHYSFS_file *file, PHYSFS_uint16 *val)
  1331. * \brief Read and convert an unsigned 16-bit bigendian value.
  1332. *
  1333. * Convenience function. Read an unsigned 16-bit bigendian value from a
  1334. * file and convert it to the platform's native byte order.
  1335. *
  1336. * \param file PhysicsFS file handle from which to read.
  1337. * \param val pointer to where value should be stored.
  1338. * \return zero on failure, non-zero on success. If successful, (*val) will
  1339. * store the result. On failure, you can find out what went wrong
  1340. * from PHYSFS_GetLastError().
  1341. *
  1342. */
  1343. __EXPORT__ int PHYSFS_readUBE16(PHYSFS_file *file, PHYSFS_uint16 *val);
  1344. /**
  1345. * \fn int PHYSFS_readSLE32(PHYSFS_file *file, PHYSFS_sint32 *val)
  1346. * \brief Read and convert a signed 32-bit littleendian value.
  1347. *
  1348. * Convenience function. Read a signed 32-bit littleendian value from a
  1349. * file and convert it to the platform's native byte order.
  1350. *
  1351. * \param file PhysicsFS file handle from which to read.
  1352. * \param val pointer to where value should be stored.
  1353. * \return zero on failure, non-zero on success. If successful, (*val) will
  1354. * store the result. On failure, you can find out what went wrong
  1355. * from PHYSFS_GetLastError().
  1356. */
  1357. __EXPORT__ int PHYSFS_readSLE32(PHYSFS_file *file, PHYSFS_sint32 *val);
  1358. /**
  1359. * \fn int PHYSFS_readULE32(PHYSFS_file *file, PHYSFS_uint32 *val)
  1360. * \brief Read and convert an unsigned 32-bit littleendian value.
  1361. *
  1362. * Convenience function. Read an unsigned 32-bit littleendian value from a
  1363. * file and convert it to the platform's native byte order.
  1364. *
  1365. * \param file PhysicsFS file handle from which to read.
  1366. * \param val pointer to where value should be stored.
  1367. * \return zero on failure, non-zero on success. If successful, (*val) will
  1368. * store the result. On failure, you can find out what went wrong
  1369. * from PHYSFS_GetLastError().
  1370. *
  1371. */
  1372. __EXPORT__ int PHYSFS_readULE32(PHYSFS_file *file, PHYSFS_uint32 *val);
  1373. /**
  1374. * \fn int PHYSFS_readSBE32(PHYSFS_file *file, PHYSFS_sint32 *val)
  1375. * \brief Read and convert a signed 32-bit bigendian value.
  1376. *
  1377. * Convenience function. Read a signed 32-bit bigendian value from a
  1378. * file and convert it to the platform's native byte order.
  1379. *
  1380. * \param file PhysicsFS file handle from which to read.
  1381. * \param val pointer to where value should be stored.
  1382. * \return zero on failure, non-zero on success. If successful, (*val) will
  1383. * store the result. On failure, you can find out what went wrong
  1384. * from PHYSFS_GetLastError().
  1385. */
  1386. __EXPORT__ int PHYSFS_readSBE32(PHYSFS_file *file, PHYSFS_sint32 *val);
  1387. /**
  1388. * \fn int PHYSFS_readUBE32(PHYSFS_file *file, PHYSFS_uint32 *val)
  1389. * \brief Read and convert an unsigned 32-bit bigendian value.
  1390. *
  1391. * Convenience function. Read an unsigned 32-bit bigendian value from a
  1392. * file and convert it to the platform's native byte order.
  1393. *
  1394. * \param file PhysicsFS file handle from which to read.
  1395. * \param val pointer to where value should be stored.
  1396. * \return zero on failure, non-zero on success. If successful, (*val) will
  1397. * store the result. On failure, you can find out what went wrong
  1398. * from PHYSFS_GetLastError().
  1399. *
  1400. */
  1401. __EXPORT__ int PHYSFS_readUBE32(PHYSFS_file *file, PHYSFS_uint32 *val);
  1402. /**
  1403. * \fn int PHYSFS_readSLE64(PHYSFS_file *file, PHYSFS_sint64 *val)
  1404. * \brief Read and convert a signed 64-bit littleendian value.
  1405. *
  1406. * Convenience function. Read a signed 64-bit littleendian value from a
  1407. * file and convert it to the platform's native byte order.
  1408. *
  1409. * \param file PhysicsFS file handle from which to read.
  1410. * \param val pointer to where value should be stored.
  1411. * \return zero on failure, non-zero on success. If successful, (*val) will
  1412. * store the result. On failure, you can find out what went wrong
  1413. * from PHYSFS_GetLastError().
  1414. *
  1415. * \warning Remember, PHYSFS_sint64 is only 32 bits on platforms without
  1416. * any sort of 64-bit support.
  1417. */
  1418. __EXPORT__ int PHYSFS_readSLE64(PHYSFS_file *file, PHYSFS_sint64 *val);
  1419. /**
  1420. * \fn int PHYSFS_readULE64(PHYSFS_file *file, PHYSFS_uint64 *val)
  1421. * \brief Read and convert an unsigned 64-bit littleendian value.
  1422. *
  1423. * Convenience function. Read an unsigned 64-bit littleendian value from a
  1424. * file and convert it to the platform's native byte order.
  1425. *
  1426. * \param file PhysicsFS file handle from which to read.
  1427. * \param val pointer to where value should be stored.
  1428. * \return zero on failure, non-zero on success. If successful, (*val) will
  1429. * store the result. On failure, you can find out what went wrong
  1430. * from PHYSFS_GetLastError().
  1431. *
  1432. * \warning Remember, PHYSFS_uint64 is only 32 bits on platforms without
  1433. * any sort of 64-bit support.
  1434. */
  1435. __EXPORT__ int PHYSFS_readULE64(PHYSFS_file *file, PHYSFS_uint64 *val);
  1436. /**
  1437. * \fn int PHYSFS_readSBE64(PHYSFS_file *file, PHYSFS_sint64 *val)
  1438. * \brief Read and convert a signed 64-bit bigendian value.
  1439. *
  1440. * Convenience function. Read a signed 64-bit bigendian value from a
  1441. * file and convert it to the platform's native byte order.
  1442. *
  1443. * \param file PhysicsFS file handle from which to read.
  1444. * \param val pointer to where value should be stored.
  1445. * \return zero on failure, non-zero on success. If successful, (*val) will
  1446. * store the result. On failure, you can find out what went wrong
  1447. * from PHYSFS_GetLastError().
  1448. *
  1449. * \warning Remember, PHYSFS_sint64 is only 32 bits on platforms without
  1450. * any sort of 64-bit support.
  1451. */
  1452. __EXPORT__ int PHYSFS_readSBE64(PHYSFS_file *file, PHYSFS_sint64 *val);
  1453. /**
  1454. * \fn int PHYSFS_readUBE64(PHYSFS_file *file, PHYSFS_uint64 *val)
  1455. * \brief Read and convert an unsigned 64-bit bigendian value.
  1456. *
  1457. * Convenience function. Read an unsigned 64-bit bigendian value from a
  1458. * file and convert it to the platform's native byte order.
  1459. *
  1460. * \param file PhysicsFS file handle from which to read.
  1461. * \param val pointer to where value should be stored.
  1462. * \return zero on failure, non-zero on success. If successful, (*val) will
  1463. * store the result. On failure, you can find out what went wrong
  1464. * from PHYSFS_GetLastError().
  1465. *
  1466. * \warning Remember, PHYSFS_uint64 is only 32 bits on platforms without
  1467. * any sort of 64-bit support.
  1468. */
  1469. __EXPORT__ int PHYSFS_readUBE64(PHYSFS_file *file, PHYSFS_uint64 *val);
  1470. /**
  1471. * \fn int PHYSFS_writeSLE16(PHYSFS_file *file, PHYSFS_sint16 val)
  1472. * \brief Convert and write a signed 16-bit littleendian value.
  1473. *
  1474. * Convenience function. Convert a signed 16-bit value from the platform's
  1475. * native byte order to littleendian and write it to a file.
  1476. *
  1477. * \param file PhysicsFS file handle to which to write.
  1478. * \param val Value to convert and write.
  1479. * \return zero on failure, non-zero on success. On failure, you can
  1480. * find out what went wrong from PHYSFS_GetLastError().
  1481. */
  1482. __EXPORT__ int PHYSFS_writeSLE16(PHYSFS_file *file, PHYSFS_sint16 val);
  1483. /**
  1484. * \fn int PHYSFS_writeULE16(PHYSFS_file *file, PHYSFS_uint16 val)
  1485. * \brief Convert and write an unsigned 16-bit littleendian value.
  1486. *
  1487. * Convenience function. Convert an unsigned 16-bit value from the platform's
  1488. * native byte order to littleendian and write it to a file.
  1489. *
  1490. * \param file PhysicsFS file handle to which to write.
  1491. * \param val Value to convert and write.
  1492. * \return zero on failure, non-zero on success. On failure, you can
  1493. * find out what went wrong from PHYSFS_GetLastError().
  1494. */
  1495. __EXPORT__ int PHYSFS_writeULE16(PHYSFS_file *file, PHYSFS_uint16 val);
  1496. /**
  1497. * \fn int PHYSFS_writeSBE16(PHYSFS_file *file, PHYSFS_sint16 val)
  1498. * \brief Convert and write a signed 16-bit bigendian value.
  1499. *
  1500. * Convenience function. Convert a signed 16-bit value from the platform's
  1501. * native byte order to bigendian and write it to a file.
  1502. *
  1503. * \param file PhysicsFS file handle to which to write.
  1504. * \param val Value to convert and write.
  1505. * \return zero on failure, non-zero on success. On failure, you can
  1506. * find out what went wrong from PHYSFS_GetLastError().
  1507. */
  1508. __EXPORT__ int PHYSFS_writeSBE16(PHYSFS_file *file, PHYSFS_sint16 val);
  1509. /**
  1510. * \fn int PHYSFS_writeUBE16(PHYSFS_file *file, PHYSFS_uint16 val)
  1511. * \brief Convert and write an unsigned 16-bit bigendian value.
  1512. *
  1513. * Convenience function. Convert an unsigned 16-bit value from the platform's
  1514. * native byte order to bigendian and write it to a file.
  1515. *
  1516. * \param file PhysicsFS file handle to which to write.
  1517. * \param val Value to convert and write.
  1518. * \return zero on failure, non-zero on success. On failure, you can
  1519. * find out what went wrong from PHYSFS_GetLastError().
  1520. */
  1521. __EXPORT__ int PHYSFS_writeUBE16(PHYSFS_file *file, PHYSFS_uint16 val);
  1522. /**
  1523. * \fn int PHYSFS_writeSLE32(PHYSFS_file *file, PHYSFS_sint32 val)
  1524. * \brief Convert and write a signed 32-bit littleendian value.
  1525. *
  1526. * Convenience function. Convert a signed 32-bit value from the platform's
  1527. * native byte order to littleendian and write it to a file.
  1528. *
  1529. * \param file PhysicsFS file handle to which to write.
  1530. * \param val Value to convert and write.
  1531. * \return zero on failure, non-zero on success. On failure, you can
  1532. * find out what went wrong from PHYSFS_GetLastError().
  1533. */
  1534. __EXPORT__ int PHYSFS_writeSLE32(PHYSFS_file *file, PHYSFS_sint32 val);
  1535. /**
  1536. * \fn int PHYSFS_writeULE32(PHYSFS_file *file, PHYSFS_uint32 val)
  1537. * \brief Convert and write an unsigned 32-bit littleendian value.
  1538. *
  1539. * Convenience function. Convert an unsigned 32-bit value from the platform's
  1540. * native byte order to littleendian and write it to a file.
  1541. *
  1542. * \param file PhysicsFS file handle to which to write.
  1543. * \param val Value to convert and write.
  1544. * \return zero on failure, non-zero on success. On failure, you can
  1545. * find out what went wrong from PHYSFS_GetLastError().
  1546. */
  1547. __EXPORT__ int PHYSFS_writeULE32(PHYSFS_file *file, PHYSFS_uint32 val);
  1548. /**
  1549. * \fn int PHYSFS_writeSBE32(PHYSFS_file *file, PHYSFS_sint32 val)
  1550. * \brief Convert and write a signed 32-bit bigendian value.
  1551. *
  1552. * Convenience function. Convert a signed 32-bit value from the platform's
  1553. * native byte order to bigendian and write it to a file.
  1554. *
  1555. * \param file PhysicsFS file handle to which to write.
  1556. * \param val Value to convert and write.
  1557. * \return zero on failure, non-zero on success. On failure, you can
  1558. * find out what went wrong from PHYSFS_GetLastError().
  1559. */
  1560. __EXPORT__ int PHYSFS_writeSBE32(PHYSFS_file *file, PHYSFS_sint32 val);
  1561. /**
  1562. * \fn int PHYSFS_writeUBE32(PHYSFS_file *file, PHYSFS_uint32 val)
  1563. * \brief Convert and write an unsigned 32-bit bigendian value.
  1564. *
  1565. * Convenience function. Convert an unsigned 32-bit value from the platform's
  1566. * native byte order to bigendian and write it to a file.
  1567. *
  1568. * \param file PhysicsFS file handle to which to write.
  1569. * \param val Value to convert and write.
  1570. * \return zero on failure, non-zero on success. On failure, you can
  1571. * find out what went wrong from PHYSFS_GetLastError().
  1572. */
  1573. __EXPORT__ int PHYSFS_writeUBE32(PHYSFS_file *file, PHYSFS_uint32 val);
  1574. /**
  1575. * \fn int PHYSFS_writeSLE64(PHYSFS_file *file, PHYSFS_sint64 val)
  1576. * \brief Convert and write a signed 64-bit littleendian value.
  1577. *
  1578. * Convenience function. Convert a signed 64-bit value from the platform's
  1579. * native byte order to littleendian and write it to a file.
  1580. *
  1581. * \param file PhysicsFS file handle to which to write.
  1582. * \param val Value to convert and write.
  1583. * \return zero on failure, non-zero on success. On failure, you can
  1584. * find out what went wrong from PHYSFS_GetLastError().
  1585. *
  1586. * \warning Remember, PHYSFS_uint64 is only 32 bits on platforms without
  1587. * any sort of 64-bit support.
  1588. */
  1589. __EXPORT__ int PHYSFS_writeSLE64(PHYSFS_file *file, PHYSFS_sint64 val);
  1590. /**
  1591. * \fn int PHYSFS_writeULE64(PHYSFS_file *file, PHYSFS_uint64 val)
  1592. * \brief Convert and write an unsigned 64-bit littleendian value.
  1593. *
  1594. * Convenience function. Convert an unsigned 64-bit value from the platform's
  1595. * native byte order to littleendian and write it to a file.
  1596. *
  1597. * \param file PhysicsFS file handle to which to write.
  1598. * \param val Value to convert and write.
  1599. * \return zero on failure, non-zero on success. On failure, you can
  1600. * find out what went wrong from PHYSFS_GetLastError().
  1601. *
  1602. * \warning Remember, PHYSFS_uint64 is only 32 bits on platforms without
  1603. * any sort of 64-bit support.
  1604. */
  1605. __EXPORT__ int PHYSFS_writeULE64(PHYSFS_file *file, PHYSFS_uint64 val);
  1606. /**
  1607. * \fn int PHYSFS_writeSBE64(PHYSFS_file *file, PHYSFS_sint64 val)
  1608. * \brief Convert and write a signed 64-bit bigending value.
  1609. *
  1610. * Convenience function. Convert a signed 64-bit value from the platform's
  1611. * native byte order to bigendian and write it to a file.
  1612. *
  1613. * \param file PhysicsFS file handle to which to write.
  1614. * \param val Value to convert and write.
  1615. * \return zero on failure, non-zero on success. On failure, you can
  1616. * find out what went wrong from PHYSFS_GetLastError().
  1617. *
  1618. * \warning Remember, PHYSFS_uint64 is only 32 bits on platforms without
  1619. * any sort of 64-bit support.
  1620. */
  1621. __EXPORT__ int PHYSFS_writeSBE64(PHYSFS_file *file, PHYSFS_sint64 val);
  1622. /**
  1623. * \fn int PHYSFS_writeUBE64(PHYSFS_file *file, PHYSFS_uint64 val)
  1624. * \brief Convert and write an unsigned 64-bit bigendian value.
  1625. *
  1626. * Convenience function. Convert an unsigned 64-bit value from the platform's
  1627. * native byte order to bigendian and write it to a file.
  1628. *
  1629. * \param file PhysicsFS file handle to which to write.
  1630. * \param val Value to convert and write.
  1631. * \return zero on failure, non-zero on success. On failure, you can
  1632. * find out what went wrong from PHYSFS_GetLastError().
  1633. *
  1634. * \warning Remember, PHYSFS_uint64 is only 32 bits on platforms without
  1635. * any sort of 64-bit support.
  1636. */
  1637. __EXPORT__ int PHYSFS_writeUBE64(PHYSFS_file *file, PHYSFS_uint64 val);
  1638. #ifdef __cplusplus
  1639. }
  1640. #endif
  1641. #endif /* !defined _INCLUDE_PHYSFS_H_ */
  1642. /* end of physfs.h ... */