physfs.h 67 KB

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