physfs.h 67 KB

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