physfs.h 64 KB

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