physfs.h 141 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543
  1. /**
  2. * \file physfs.h
  3. *
  4. * Main header file for PhysicsFS.
  5. */
  6. /**
  7. * \mainpage PhysicsFS
  8. *
  9. * The latest version of PhysicsFS can be found at:
  10. * http://icculus.org/physfs/
  11. *
  12. * PhysicsFS; a portable, flexible file i/o abstraction.
  13. *
  14. * This API gives you access to a system file system in ways superior to the
  15. * stdio or system i/o calls. The brief benefits:
  16. *
  17. * - It's portable.
  18. * - It's safe. No file access is permitted outside the specified dirs.
  19. * - It's flexible. Archives (.ZIP files) can be used transparently as
  20. * directory structures.
  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.
  75. * Remember that most archive types and platform filesystems store their
  76. * filenames in a case-sensitive manner, so you should be careful to specify
  77. * it correctly.
  78. *
  79. * Files opened through PhysicsFS may NOT contain "." or ".." or ":" as dir
  80. * elements. Not only are these meaningless on MacOS Classic and/or Unix,
  81. * they are a security hole. Also, symbolic links (which can be found in
  82. * some archive types and directly in the filesystem on Unix platforms) are
  83. * NOT followed until you call PHYSFS_permitSymbolicLinks(). That's left to
  84. * your own discretion, as following a symlink can allow for access outside
  85. * the write dir and search paths. For portability, there is no mechanism for
  86. * creating new symlinks in PhysicsFS.
  87. *
  88. * The write dir is not included in the search path unless you specifically
  89. * add it. While you CAN change the write dir as many times as you like,
  90. * you should probably set it once and stick to it. Remember that your
  91. * program will not have permission to write in every directory on Unix and
  92. * NT systems.
  93. *
  94. * All files are opened in binary mode; there is no endline conversion for
  95. * textfiles. Other than that, PhysicsFS has some convenience functions for
  96. * platform-independence. There is a function to tell you the current
  97. * platform's dir separator ("\\" on windows, "/" on Unix, ":" on MacOS),
  98. * which is needed only to set up your search/write paths. There is a
  99. * function to tell you what CD-ROM drives contain accessible discs, and a
  100. * function to recommend a good search path, etc.
  101. *
  102. * A recommended order for the search path is the write dir, then the base dir,
  103. * then the cdrom dir, then any archives discovered. Quake 3 does something
  104. * like this, but moves the archives to the start of the search path. Build
  105. * Engine games, like Duke Nukem 3D and Blood, place the archives last, and
  106. * use the base dir for both searching and writing. There is a helper
  107. * function (PHYSFS_setSaneConfig()) that puts together a basic configuration
  108. * for you, based on a few parameters. Also see the comments on
  109. * PHYSFS_getBaseDir(), and PHYSFS_getPrefDir() for info on what those
  110. * are and how they can help you determine an optimal search path.
  111. *
  112. * PhysicsFS 2.0 adds the concept of "mounting" archives to arbitrary points
  113. * in the search path. If a zipfile contains "maps/level.map" and you mount
  114. * that archive at "mods/mymod", then you would have to open
  115. * "mods/mymod/maps/level.map" to access the file, even though "mods/mymod"
  116. * isn't actually specified in the .zip file. Unlike the Unix mentality of
  117. * mounting a filesystem, "mods/mymod" doesn't actually have to exist when
  118. * mounting the zipfile. It's a "virtual" directory. The mounting mechanism
  119. * allows the developer to seperate archives in the tree and avoid trampling
  120. * over files when added new archives, such as including mod support in a
  121. * game...keeping external content on a tight leash in this manner can be of
  122. * utmost importance to some applications.
  123. *
  124. * PhysicsFS is mostly thread safe. The error messages returned by
  125. * PHYSFS_getLastError() are unique by thread, and library-state-setting
  126. * functions are mutex'd. For efficiency, individual file accesses are
  127. * not locked, so you can not safely read/write/seek/close/etc the same
  128. * file from two threads at the same time. Other race conditions are bugs
  129. * that should be reported/patched.
  130. *
  131. * While you CAN use stdio/syscall file access in a program that has PHYSFS_*
  132. * calls, doing so is not recommended, and you can not use system
  133. * filehandles with PhysicsFS and vice versa.
  134. *
  135. * Note that archives need not be named as such: if you have a ZIP file and
  136. * rename it with a .PKG extension, the file will still be recognized as a
  137. * ZIP archive by PhysicsFS; the file's contents are used to determine its
  138. * type where possible.
  139. *
  140. * Currently supported archive types:
  141. * - .ZIP (pkZip/WinZip/Info-ZIP compatible)
  142. * - .7Z (7zip archives)
  143. * - .ISO (ISO9660 files, CD-ROM images)
  144. * - .GRP (Build Engine groupfile archives)
  145. * - .PAK (Quake I/II archive format)
  146. * - .HOG (Descent I/II HOG file archives)
  147. * - .MVL (Descent II movielib archives)
  148. * - .WAD (DOOM engine archives)
  149. *
  150. *
  151. * String policy for PhysicsFS 2.0 and later:
  152. *
  153. * PhysicsFS 1.0 could only deal with null-terminated ASCII strings. All high
  154. * ASCII chars resulted in undefined behaviour, and there was no Unicode
  155. * support at all. PhysicsFS 2.0 supports Unicode without breaking binary
  156. * compatibility with the 1.0 API by using UTF-8 encoding of all strings
  157. * passed in and out of the library.
  158. *
  159. * All strings passed through PhysicsFS are in null-terminated UTF-8 format.
  160. * This means that if all you care about is English (ASCII characters <= 127)
  161. * then you just use regular C strings. If you care about Unicode (and you
  162. * should!) then you need to figure out what your platform wants, needs, and
  163. * offers. If you are on Windows before Win2000 and build with Unicode
  164. * support, your TCHAR strings are two bytes per character (this is called
  165. * "UCS-2 encoding"). Any modern Windows uses UTF-16, which is two bytes
  166. * per character for most characters, but some characters are four. You
  167. * should convert them to UTF-8 before handing them to PhysicsFS with
  168. * PHYSFS_utf8FromUtf16(), which handles both UTF-16 and UCS-2. If you're
  169. * using Unix or Mac OS X, your wchar_t strings are four bytes per character
  170. * ("UCS-4 encoding"). Use PHYSFS_utf8FromUcs4(). Mac OS X can give you UTF-8
  171. * directly from a CFString or NSString, and many Unixes generally give you C
  172. * strings in UTF-8 format everywhere. If you have a single-byte high ASCII
  173. * charset, like so-many European "codepages" you may be out of luck. We'll
  174. * convert from "Latin1" to UTF-8 only, and never back to Latin1. If you're
  175. * above ASCII 127, all bets are off: move to Unicode or use your platform's
  176. * facilities. Passing a C string with high-ASCII data that isn't UTF-8
  177. * encoded will NOT do what you expect!
  178. *
  179. * Naturally, there's also PHYSFS_utf8ToUcs2(), PHYSFS_utf8ToUtf16(), and
  180. * PHYSFS_utf8ToUcs4() to get data back into a format you like. Behind the
  181. * scenes, PhysicsFS will use Unicode where possible: the UTF-8 strings on
  182. * Windows will be converted and used with the multibyte Windows APIs, for
  183. * example.
  184. *
  185. * PhysicsFS offers basic encoding conversion support, but not a whole string
  186. * library. Get your stuff into whatever format you can work with.
  187. *
  188. * All platforms supported by PhysicsFS 2.1 and later fully support Unicode.
  189. * We have dropped platforms that don't (OS/2, Mac OS 9, Windows 95, etc), as
  190. * even an OS that's over a decade old should be expected to handle this well.
  191. * If you absolutely must support one of these platforms, you should use an
  192. * older release of PhysicsFS.
  193. *
  194. * Many game-specific archivers are seriously unprepared for Unicode (the
  195. * Descent HOG/MVL and Build Engine GRP archivers, for example, only offer a
  196. * DOS 8.3 filename, for example). Nothing can be done for these, but they
  197. * tend to be legacy formats for existing content that was all ASCII (and
  198. * thus, valid UTF-8) anyhow. Other formats, like .ZIP, don't explicitly
  199. * offer Unicode support, but unofficially expect filenames to be UTF-8
  200. * encoded, and thus Just Work. Most everything does the right thing without
  201. * bothering you, but it's good to be aware of these nuances in case they
  202. * don't.
  203. *
  204. *
  205. * Other stuff:
  206. *
  207. * Please see the file LICENSE.txt in the source's root directory for
  208. * licensing and redistribution rights.
  209. *
  210. * Please see the file CREDITS.txt in the source's "docs" directory for
  211. * a more or less complete list of who's responsible for this.
  212. *
  213. * \author Ryan C. Gordon.
  214. */
  215. #ifndef _INCLUDE_PHYSFS_H_
  216. #define _INCLUDE_PHYSFS_H_
  217. #ifdef __cplusplus
  218. extern "C" {
  219. #endif
  220. #if defined(PHYSFS_DECL)
  221. /* do nothing. */
  222. #elif (defined SWIG)
  223. #define PHYSFS_DECL extern
  224. #elif (defined _MSC_VER)
  225. #define PHYSFS_DECL __declspec(dllexport)
  226. #elif (defined __SUNPRO_C)
  227. #define PHYSFS_DECL __global
  228. #elif ((__GNUC__ >= 3) && (!__EMX__) && (!sun))
  229. #define PHYSFS_DECL __attribute__((visibility("default")))
  230. #else
  231. #define PHYSFS_DECL
  232. #endif
  233. #if defined(PHYSFS_DEPRECATED)
  234. /* do nothing. */
  235. #elif (defined SWIG) /* ignore deprecated, since bindings use everything. */
  236. #define PHYSFS_DEPRECATED
  237. #elif (__GNUC__ >= 4) /* technically, this arrived in gcc 3.1, but oh well. */
  238. #define PHYSFS_DEPRECATED __attribute__((deprecated))
  239. #else
  240. #define PHYSFS_DEPRECATED
  241. #endif
  242. #if 0 /* !!! FIXME: look into this later. */
  243. #if defined(PHYSFS_CALL)
  244. /* do nothing. */
  245. #elif defined(__WIN32__) && !defined(__GNUC__)
  246. #define PHYSFS_CALL __cdecl
  247. #else
  248. #define PHYSFS_CALL
  249. #endif
  250. #endif
  251. /**
  252. * \typedef PHYSFS_uint8
  253. * \brief An unsigned, 8-bit integer type.
  254. */
  255. typedef unsigned char PHYSFS_uint8;
  256. /**
  257. * \typedef PHYSFS_sint8
  258. * \brief A signed, 8-bit integer type.
  259. */
  260. typedef signed char PHYSFS_sint8;
  261. /**
  262. * \typedef PHYSFS_uint16
  263. * \brief An unsigned, 16-bit integer type.
  264. */
  265. typedef unsigned short PHYSFS_uint16;
  266. /**
  267. * \typedef PHYSFS_sint16
  268. * \brief A signed, 16-bit integer type.
  269. */
  270. typedef signed short PHYSFS_sint16;
  271. /**
  272. * \typedef PHYSFS_uint32
  273. * \brief An unsigned, 32-bit integer type.
  274. */
  275. typedef unsigned int PHYSFS_uint32;
  276. /**
  277. * \typedef PHYSFS_sint32
  278. * \brief A signed, 32-bit integer type.
  279. */
  280. typedef signed int PHYSFS_sint32;
  281. /**
  282. * \typedef PHYSFS_uint64
  283. * \brief An unsigned, 64-bit integer type.
  284. * \warning on platforms without any sort of 64-bit datatype, this is
  285. * equivalent to PHYSFS_uint32!
  286. */
  287. /**
  288. * \typedef PHYSFS_sint64
  289. * \brief A signed, 64-bit integer type.
  290. * \warning on platforms without any sort of 64-bit datatype, this is
  291. * equivalent to PHYSFS_sint32!
  292. */
  293. #if (defined PHYSFS_NO_64BIT_SUPPORT) /* oh well. */
  294. typedef PHYSFS_uint32 PHYSFS_uint64;
  295. typedef PHYSFS_sint32 PHYSFS_sint64;
  296. #elif (defined _MSC_VER)
  297. typedef signed __int64 PHYSFS_sint64;
  298. typedef unsigned __int64 PHYSFS_uint64;
  299. #else
  300. typedef unsigned long long PHYSFS_uint64;
  301. typedef signed long long PHYSFS_sint64;
  302. #endif
  303. #ifndef SWIG
  304. #ifndef DOXYGEN_SHOULD_IGNORE_THIS
  305. /* Make sure the types really have the right sizes */
  306. #define PHYSFS_COMPILE_TIME_ASSERT(name, x) \
  307. typedef int PHYSFS_dummy_ ## name[(x) * 2 - 1]
  308. PHYSFS_COMPILE_TIME_ASSERT(uint8, sizeof(PHYSFS_uint8) == 1);
  309. PHYSFS_COMPILE_TIME_ASSERT(sint8, sizeof(PHYSFS_sint8) == 1);
  310. PHYSFS_COMPILE_TIME_ASSERT(uint16, sizeof(PHYSFS_uint16) == 2);
  311. PHYSFS_COMPILE_TIME_ASSERT(sint16, sizeof(PHYSFS_sint16) == 2);
  312. PHYSFS_COMPILE_TIME_ASSERT(uint32, sizeof(PHYSFS_uint32) == 4);
  313. PHYSFS_COMPILE_TIME_ASSERT(sint32, sizeof(PHYSFS_sint32) == 4);
  314. #ifndef PHYSFS_NO_64BIT_SUPPORT
  315. PHYSFS_COMPILE_TIME_ASSERT(uint64, sizeof(PHYSFS_uint64) == 8);
  316. PHYSFS_COMPILE_TIME_ASSERT(sint64, sizeof(PHYSFS_sint64) == 8);
  317. #endif
  318. #undef PHYSFS_COMPILE_TIME_ASSERT
  319. #endif /* DOXYGEN_SHOULD_IGNORE_THIS */
  320. #endif /* SWIG */
  321. /**
  322. * \struct PHYSFS_File
  323. * \brief A PhysicsFS file handle.
  324. *
  325. * You get a pointer to one of these when you open a file for reading,
  326. * writing, or appending via PhysicsFS.
  327. *
  328. * As you can see from the lack of meaningful fields, you should treat this
  329. * as opaque data. Don't try to manipulate the file handle, just pass the
  330. * pointer you got, unmolested, to various PhysicsFS APIs.
  331. *
  332. * \sa PHYSFS_openRead
  333. * \sa PHYSFS_openWrite
  334. * \sa PHYSFS_openAppend
  335. * \sa PHYSFS_close
  336. * \sa PHYSFS_read
  337. * \sa PHYSFS_write
  338. * \sa PHYSFS_seek
  339. * \sa PHYSFS_tell
  340. * \sa PHYSFS_eof
  341. * \sa PHYSFS_setBuffer
  342. * \sa PHYSFS_flush
  343. */
  344. typedef struct PHYSFS_File
  345. {
  346. void *opaque; /**< That's all you get. Don't touch. */
  347. } PHYSFS_File;
  348. /**
  349. * \def PHYSFS_file
  350. * \brief 1.0 API compatibility define.
  351. *
  352. * PHYSFS_file is identical to PHYSFS_File. This #define is here for backwards
  353. * compatibility with the 1.0 API, which had an inconsistent capitalization
  354. * convention in this case. New code should use PHYSFS_File, as this #define
  355. * may go away someday.
  356. *
  357. * \sa PHYSFS_File
  358. */
  359. #define PHYSFS_file PHYSFS_File
  360. /**
  361. * \struct PHYSFS_ArchiveInfo
  362. * \brief Information on various PhysicsFS-supported archives.
  363. *
  364. * This structure gives you details on what sort of archives are supported
  365. * by this implementation of PhysicsFS. Archives tend to be things like
  366. * ZIP files and such.
  367. *
  368. * \warning Not all binaries are created equal! PhysicsFS can be built with
  369. * or without support for various archives. You can check with
  370. * PHYSFS_supportedArchiveTypes() to see if your archive type is
  371. * supported.
  372. *
  373. * \sa PHYSFS_supportedArchiveTypes
  374. * \sa PHYSFS_registerArchiver
  375. * \sa PHYSFS_deregisterArchiver
  376. */
  377. typedef struct PHYSFS_ArchiveInfo
  378. {
  379. const char *extension; /**< Archive file extension: "ZIP", for example. */
  380. const char *description; /**< Human-readable archive description. */
  381. const char *author; /**< Person who did support for this archive. */
  382. const char *url; /**< URL related to this archive */
  383. int supportsSymlinks; /**< non-zero if archive offers symbolic links. */
  384. } PHYSFS_ArchiveInfo;
  385. /**
  386. * \struct PHYSFS_Version
  387. * \brief Information the version of PhysicsFS in use.
  388. *
  389. * Represents the library's version as three levels: major revision
  390. * (increments with massive changes, additions, and enhancements),
  391. * minor revision (increments with backwards-compatible changes to the
  392. * major revision), and patchlevel (increments with fixes to the minor
  393. * revision).
  394. *
  395. * \sa PHYSFS_VERSION
  396. * \sa PHYSFS_getLinkedVersion
  397. */
  398. typedef struct PHYSFS_Version
  399. {
  400. PHYSFS_uint8 major; /**< major revision */
  401. PHYSFS_uint8 minor; /**< minor revision */
  402. PHYSFS_uint8 patch; /**< patchlevel */
  403. } PHYSFS_Version;
  404. #ifndef SWIG /* not available from scripting languages. */
  405. #ifndef DOXYGEN_SHOULD_IGNORE_THIS
  406. #define PHYSFS_VER_MAJOR 2
  407. #define PHYSFS_VER_MINOR 1
  408. #define PHYSFS_VER_PATCH 0
  409. #endif /* DOXYGEN_SHOULD_IGNORE_THIS */
  410. /* PhysicsFS state stuff ... */
  411. /**
  412. * \def PHYSFS_VERSION(x)
  413. * \brief Macro to determine PhysicsFS version program was compiled against.
  414. *
  415. * This macro fills in a PHYSFS_Version structure with the version of the
  416. * library you compiled against. This is determined by what header the
  417. * compiler uses. Note that if you dynamically linked the library, you might
  418. * have a slightly newer or older version at runtime. That version can be
  419. * determined with PHYSFS_getLinkedVersion(), which, unlike PHYSFS_VERSION,
  420. * is not a macro.
  421. *
  422. * \param x A pointer to a PHYSFS_Version struct to initialize.
  423. *
  424. * \sa PHYSFS_Version
  425. * \sa PHYSFS_getLinkedVersion
  426. */
  427. #define PHYSFS_VERSION(x) \
  428. { \
  429. (x)->major = PHYSFS_VER_MAJOR; \
  430. (x)->minor = PHYSFS_VER_MINOR; \
  431. (x)->patch = PHYSFS_VER_PATCH; \
  432. }
  433. #endif /* SWIG */
  434. /**
  435. * \fn void PHYSFS_getLinkedVersion(PHYSFS_Version *ver)
  436. * \brief Get the version of PhysicsFS that is linked against your program.
  437. *
  438. * If you are using a shared library (DLL) version of PhysFS, then it is
  439. * possible that it will be different than the version you compiled against.
  440. *
  441. * This is a real function; the macro PHYSFS_VERSION tells you what version
  442. * of PhysFS you compiled against:
  443. *
  444. * \code
  445. * PHYSFS_Version compiled;
  446. * PHYSFS_Version linked;
  447. *
  448. * PHYSFS_VERSION(&compiled);
  449. * PHYSFS_getLinkedVersion(&linked);
  450. * printf("We compiled against PhysFS version %d.%d.%d ...\n",
  451. * compiled.major, compiled.minor, compiled.patch);
  452. * printf("But we linked against PhysFS version %d.%d.%d.\n",
  453. * linked.major, linked.minor, linked.patch);
  454. * \endcode
  455. *
  456. * This function may be called safely at any time, even before PHYSFS_init().
  457. *
  458. * \sa PHYSFS_VERSION
  459. */
  460. PHYSFS_DECL void PHYSFS_getLinkedVersion(PHYSFS_Version *ver);
  461. /**
  462. * \fn int PHYSFS_init(const char *argv0)
  463. * \brief Initialize the PhysicsFS library.
  464. *
  465. * This must be called before any other PhysicsFS function.
  466. *
  467. * This should be called prior to any attempts to change your process's
  468. * current working directory.
  469. *
  470. * \param argv0 the argv[0] string passed to your program's mainline.
  471. * This may be NULL on most platforms (such as ones without a
  472. * standard main() function), but you should always try to pass
  473. * something in here. Unix-like systems such as Linux _need_ to
  474. * pass argv[0] from main() in here.
  475. * \return nonzero on success, zero on error. Specifics of the error can be
  476. * gleaned from PHYSFS_getLastError().
  477. *
  478. * \sa PHYSFS_deinit
  479. * \sa PHYSFS_isInit
  480. */
  481. PHYSFS_DECL int PHYSFS_init(const char *argv0);
  482. /**
  483. * \fn int PHYSFS_deinit(void)
  484. * \brief Deinitialize the PhysicsFS library.
  485. *
  486. * This closes any files opened via PhysicsFS, blanks the search/write paths,
  487. * frees memory, and invalidates all of your file handles.
  488. *
  489. * Note that this call can FAIL if there's a file open for writing that
  490. * refuses to close (for example, the underlying operating system was
  491. * buffering writes to network filesystem, and the fileserver has crashed,
  492. * or a hard drive has failed, etc). It is usually best to close all write
  493. * handles yourself before calling this function, so that you can gracefully
  494. * handle a specific failure.
  495. *
  496. * Once successfully deinitialized, PHYSFS_init() can be called again to
  497. * restart the subsystem. All default API states are restored at this
  498. * point, with the exception of any custom allocator you might have
  499. * specified, which survives between initializations.
  500. *
  501. * \return nonzero on success, zero on error. Specifics of the error can be
  502. * gleaned from PHYSFS_getLastError(). If failure, state of PhysFS is
  503. * undefined, and probably badly screwed up.
  504. *
  505. * \sa PHYSFS_init
  506. * \sa PHYSFS_isInit
  507. */
  508. PHYSFS_DECL int PHYSFS_deinit(void);
  509. /**
  510. * \fn const PHYSFS_ArchiveInfo **PHYSFS_supportedArchiveTypes(void)
  511. * \brief Get a list of supported archive types.
  512. *
  513. * Get a list of archive types supported by this implementation of PhysicFS.
  514. * These are the file formats usable for search path entries. This is for
  515. * informational purposes only. Note that the extension listed is merely
  516. * convention: if we list "ZIP", you can open a PkZip-compatible archive
  517. * with an extension of "XYZ", if you like.
  518. *
  519. * The returned value is an array of pointers to PHYSFS_ArchiveInfo structures,
  520. * with a NULL entry to signify the end of the list:
  521. *
  522. * \code
  523. * PHYSFS_ArchiveInfo **i;
  524. *
  525. * for (i = PHYSFS_supportedArchiveTypes(); *i != NULL; i++)
  526. * {
  527. * printf("Supported archive: [%s], which is [%s].\n",
  528. * (*i)->extension, (*i)->description);
  529. * }
  530. * \endcode
  531. *
  532. * The return values are pointers to internal memory, and should
  533. * be considered READ ONLY, and never freed. The returned values are
  534. * valid until the next call to PHYSFS_deinit(), PHYSFS_registerArchiver(),
  535. * or PHYSFS_deregisterArchiver().
  536. *
  537. * \return READ ONLY Null-terminated array of READ ONLY structures.
  538. *
  539. * \sa PHYSFS_registerArchiver
  540. * \sa PHYSFS_deregisterArchiver
  541. */
  542. PHYSFS_DECL const PHYSFS_ArchiveInfo **PHYSFS_supportedArchiveTypes(void);
  543. /**
  544. * \fn void PHYSFS_freeList(void *listVar)
  545. * \brief Deallocate resources of lists returned by PhysicsFS.
  546. *
  547. * Certain PhysicsFS functions return lists of information that are
  548. * dynamically allocated. Use this function to free those resources.
  549. *
  550. * It is safe to pass a NULL here, but doing so will cause a crash in versions
  551. * before PhysicsFS 2.1.0.
  552. *
  553. * \param listVar List of information specified as freeable by this function.
  554. * Passing NULL is safe; it is a valid no-op.
  555. *
  556. * \sa PHYSFS_getCdRomDirs
  557. * \sa PHYSFS_enumerateFiles
  558. * \sa PHYSFS_getSearchPath
  559. */
  560. PHYSFS_DECL void PHYSFS_freeList(void *listVar);
  561. /**
  562. * \fn const char *PHYSFS_getLastError(void)
  563. * \brief Get human-readable error information.
  564. *
  565. * \warning As of PhysicsFS 2.1, this function has been nerfed.
  566. * Before PhysicsFS 2.1, this function was the only way to get
  567. * error details beyond a given function's basic return value.
  568. * This was meant to be a human-readable string in one of several
  569. * languages, and was not useful for application parsing. This was
  570. * a problem, because the developer and not the user chose the
  571. * language at compile time, and the PhysicsFS maintainers had
  572. * to (poorly) maintain a significant amount of localization work.
  573. * The app couldn't parse the strings, even if they counted on a
  574. * specific language, since some were dynamically generated.
  575. * In 2.1 and later, this always returns a static string in
  576. * English; you may use it as a key string for your own
  577. * localizations if you like, as we'll promise not to change
  578. * existing error strings. Also, if your application wants to
  579. * look at specific errors, we now offer a better option:
  580. * use PHYSFS_getLastErrorCode() instead.
  581. *
  582. * Get the last PhysicsFS error message as a human-readable, null-terminated
  583. * string. This will return NULL if there's been no error since the last call
  584. * to this function. The pointer returned by this call points to an internal
  585. * buffer. Each thread has a unique error state associated with it, but each
  586. * time a new error message is set, it will overwrite the previous one
  587. * associated with that thread. It is safe to call this function at anytime,
  588. * even before PHYSFS_init().
  589. *
  590. * PHYSFS_getLastError() and PHYSFS_getLastErrorCode() both reset the same
  591. * thread-specific error state. Calling one will wipe out the other's
  592. * data. If you need both, call PHYSFS_getLastErrorCode(), then pass that
  593. * value to PHYSFS_getErrorByCode().
  594. *
  595. * As of PhysicsFS 2.1, this function only presents text in the English
  596. * language, but the strings are static, so you can use them as keys into
  597. * your own localization dictionary. These strings are meant to be passed on
  598. * directly to the user.
  599. *
  600. * Generally, applications should only concern themselves with whether a
  601. * given function failed; however, if your code require more specifics, you
  602. * should use PHYSFS_getLastErrorCode() instead of this function.
  603. *
  604. * \return READ ONLY string of last error message.
  605. *
  606. * \sa PHYSFS_getLastErrorCode
  607. * \sa PHYSFS_getErrorByCode
  608. */
  609. PHYSFS_DECL const char *PHYSFS_getLastError(void);
  610. /**
  611. * \fn const char *PHYSFS_getDirSeparator(void)
  612. * \brief Get platform-dependent dir separator string.
  613. *
  614. * This returns "\\" on win32, "/" on Unix, and ":" on MacOS. It may be more
  615. * than one character, depending on the platform, and your code should take
  616. * that into account. Note that this is only useful for setting up the
  617. * search/write paths, since access into those dirs always use '/'
  618. * (platform-independent notation) to separate directories. This is also
  619. * handy for getting platform-independent access when using stdio calls.
  620. *
  621. * \return READ ONLY null-terminated string of platform's dir separator.
  622. */
  623. PHYSFS_DECL const char *PHYSFS_getDirSeparator(void);
  624. /**
  625. * \fn void PHYSFS_permitSymbolicLinks(int allow)
  626. * \brief Enable or disable following of symbolic links.
  627. *
  628. * Some physical filesystems and archives contain files that are just pointers
  629. * to other files. On the physical filesystem, opening such a link will
  630. * (transparently) open the file that is pointed to.
  631. *
  632. * By default, PhysicsFS will check if a file is really a symlink during open
  633. * calls and fail if it is. Otherwise, the link could take you outside the
  634. * write and search paths, and compromise security.
  635. *
  636. * If you want to take that risk, call this function with a non-zero parameter.
  637. * Note that this is more for sandboxing a program's scripting language, in
  638. * case untrusted scripts try to compromise the system. Generally speaking,
  639. * a user could very well have a legitimate reason to set up a symlink, so
  640. * unless you feel there's a specific danger in allowing them, you should
  641. * permit them.
  642. *
  643. * Symlinks are only explicitly checked when dealing with filenames
  644. * in platform-independent notation. That is, when setting up your
  645. * search and write paths, etc, symlinks are never checked for.
  646. *
  647. * Please note that PHYSFS_stat() will always check the path specified; if
  648. * that path is a symlink, it will not be followed in any case. If symlinks
  649. * aren't permitted through this function, PHYSFS_stat() ignores them, and
  650. * would treat the query as if the path didn't exist at all.
  651. *
  652. * Symbolic link permission can be enabled or disabled at any time after
  653. * you've called PHYSFS_init(), and is disabled by default.
  654. *
  655. * \param allow nonzero to permit symlinks, zero to deny linking.
  656. *
  657. * \sa PHYSFS_symbolicLinksPermitted
  658. */
  659. PHYSFS_DECL void PHYSFS_permitSymbolicLinks(int allow);
  660. /* !!! FIXME: const this? */
  661. /**
  662. * \fn char **PHYSFS_getCdRomDirs(void)
  663. * \brief Get an array of paths to available CD-ROM drives.
  664. *
  665. * The dirs returned are platform-dependent ("D:\" on Win32, "/cdrom" or
  666. * whatnot on Unix). Dirs are only returned if there is a disc ready and
  667. * accessible in the drive. So if you've got two drives (D: and E:), and only
  668. * E: has a disc in it, then that's all you get. If the user inserts a disc
  669. * in D: and you call this function again, you get both drives. If, on a
  670. * Unix box, the user unmounts a disc and remounts it elsewhere, the next
  671. * call to this function will reflect that change.
  672. *
  673. * This function refers to "CD-ROM" media, but it really means "inserted disc
  674. * media," such as DVD-ROM, HD-DVD, CDRW, and Blu-Ray discs. It looks for
  675. * filesystems, and as such won't report an audio CD, unless there's a
  676. * mounted filesystem track on it.
  677. *
  678. * The returned value is an array of strings, with a NULL entry to signify the
  679. * end of the list:
  680. *
  681. * \code
  682. * char **cds = PHYSFS_getCdRomDirs();
  683. * char **i;
  684. *
  685. * for (i = cds; *i != NULL; i++)
  686. * printf("cdrom dir [%s] is available.\n", *i);
  687. *
  688. * PHYSFS_freeList(cds);
  689. * \endcode
  690. *
  691. * This call may block while drives spin up. Be forewarned.
  692. *
  693. * When you are done with the returned information, you may dispose of the
  694. * resources by calling PHYSFS_freeList() with the returned pointer.
  695. *
  696. * \return Null-terminated array of null-terminated strings.
  697. *
  698. * \sa PHYSFS_getCdRomDirsCallback
  699. */
  700. PHYSFS_DECL char **PHYSFS_getCdRomDirs(void);
  701. /**
  702. * \fn const char *PHYSFS_getBaseDir(void)
  703. * \brief Get the path where the application resides.
  704. *
  705. * Helper function.
  706. *
  707. * Get the "base dir". This is the directory where the application was run
  708. * from, which is probably the installation directory, and may or may not
  709. * be the process's current working directory.
  710. *
  711. * You should probably use the base dir in your search path.
  712. *
  713. * \return READ ONLY string of base dir in platform-dependent notation.
  714. *
  715. * \sa PHYSFS_getPrefDir
  716. */
  717. PHYSFS_DECL const char *PHYSFS_getBaseDir(void);
  718. /**
  719. * \fn const char *PHYSFS_getUserDir(void)
  720. * \brief Get the path where user's home directory resides.
  721. *
  722. * \deprecated As of PhysicsFS 2.1, you probably want PHYSFS_getPrefDir().
  723. *
  724. * Helper function.
  725. *
  726. * Get the "user dir". This is meant to be a suggestion of where a specific
  727. * user of the system can store files. On Unix, this is her home directory.
  728. * On systems with no concept of multiple home directories (MacOS, win95),
  729. * this will default to something like "C:\mybasedir\users\username"
  730. * where "username" will either be the login name, or "default" if the
  731. * platform doesn't support multiple users, either.
  732. *
  733. * \return READ ONLY string of user dir in platform-dependent notation.
  734. *
  735. * \sa PHYSFS_getBaseDir
  736. * \sa PHYSFS_getPrefDir
  737. */
  738. PHYSFS_DECL const char *PHYSFS_getUserDir(void) PHYSFS_DEPRECATED;
  739. /**
  740. * \fn const char *PHYSFS_getWriteDir(void)
  741. * \brief Get path where PhysicsFS will allow file writing.
  742. *
  743. * Get the current write dir. The default write dir is NULL.
  744. *
  745. * \return READ ONLY string of write dir in platform-dependent notation,
  746. * OR NULL IF NO WRITE PATH IS CURRENTLY SET.
  747. *
  748. * \sa PHYSFS_setWriteDir
  749. */
  750. PHYSFS_DECL const char *PHYSFS_getWriteDir(void);
  751. /**
  752. * \fn int PHYSFS_setWriteDir(const char *newDir)
  753. * \brief Tell PhysicsFS where it may write files.
  754. *
  755. * Set a new write dir. This will override the previous setting.
  756. *
  757. * This call will fail (and fail to change the write dir) if the current
  758. * write dir still has files open in it.
  759. *
  760. * \param newDir The new directory to be the root of the write dir,
  761. * specified in platform-dependent notation. Setting to NULL
  762. * disables the write dir, so no files can be opened for
  763. * writing via PhysicsFS.
  764. * \return non-zero on success, zero on failure. All attempts to open a file
  765. * for writing via PhysicsFS will fail until this call succeeds.
  766. * Specifics of the error can be gleaned from PHYSFS_getLastError().
  767. *
  768. * \sa PHYSFS_getWriteDir
  769. */
  770. PHYSFS_DECL int PHYSFS_setWriteDir(const char *newDir);
  771. /**
  772. * \fn int PHYSFS_addToSearchPath(const char *newDir, int appendToPath)
  773. * \brief Add an archive or directory to the search path.
  774. *
  775. * \deprecated As of PhysicsFS 2.0, use PHYSFS_mount() instead. This
  776. * function just wraps it anyhow.
  777. *
  778. * This function is equivalent to:
  779. *
  780. * \code
  781. * PHYSFS_mount(newDir, NULL, appendToPath);
  782. * \endcode
  783. *
  784. * You must use this and not PHYSFS_mount if binary compatibility with
  785. * PhysicsFS 1.0 is important (which it may not be for many people).
  786. *
  787. * \sa PHYSFS_mount
  788. * \sa PHYSFS_removeFromSearchPath
  789. * \sa PHYSFS_getSearchPath
  790. */
  791. PHYSFS_DECL int PHYSFS_addToSearchPath(const char *newDir, int appendToPath)
  792. PHYSFS_DEPRECATED;
  793. /**
  794. * \fn int PHYSFS_removeFromSearchPath(const char *oldDir)
  795. * \brief Remove a directory or archive from the search path.
  796. *
  797. * \deprecated As of PhysicsFS 2.1, use PHYSFS_unmount() instead. This
  798. * function just wraps it anyhow. There's no functional difference
  799. * except the vocabulary changed from "adding to the search path"
  800. * to "mounting" when that functionality was extended, and thus
  801. * the preferred way to accomplish this function's work is now
  802. * called "unmounting."
  803. *
  804. * This function is equivalent to:
  805. *
  806. * \code
  807. * PHYSFS_unmount(oldDir);
  808. * \endcode
  809. *
  810. * You must use this and not PHYSFS_unmount if binary compatibility with
  811. * PhysicsFS 1.0 is important (which it may not be for many people).
  812. *
  813. * \sa PHYSFS_addToSearchPath
  814. * \sa PHYSFS_getSearchPath
  815. * \sa PHYSFS_unmount
  816. */
  817. PHYSFS_DECL int PHYSFS_removeFromSearchPath(const char *oldDir)
  818. PHYSFS_DEPRECATED;
  819. /**
  820. * \fn char **PHYSFS_getSearchPath(void)
  821. * \brief Get the current search path.
  822. *
  823. * The default search path is an empty list.
  824. *
  825. * The returned value is an array of strings, with a NULL entry to signify the
  826. * end of the list:
  827. *
  828. * \code
  829. * char **i;
  830. *
  831. * for (i = PHYSFS_getSearchPath(); *i != NULL; i++)
  832. * printf("[%s] is in the search path.\n", *i);
  833. * \endcode
  834. *
  835. * When you are done with the returned information, you may dispose of the
  836. * resources by calling PHYSFS_freeList() with the returned pointer.
  837. *
  838. * \return Null-terminated array of null-terminated strings. NULL if there
  839. * was a problem (read: OUT OF MEMORY).
  840. *
  841. * \sa PHYSFS_getSearchPathCallback
  842. * \sa PHYSFS_addToSearchPath
  843. * \sa PHYSFS_removeFromSearchPath
  844. */
  845. PHYSFS_DECL char **PHYSFS_getSearchPath(void);
  846. /**
  847. * \fn int PHYSFS_setSaneConfig(const char *organization, const char *appName, const char *archiveExt, int includeCdRoms, int archivesFirst)
  848. * \brief Set up sane, default paths.
  849. *
  850. * Helper function.
  851. *
  852. * The write dir will be set to the pref dir returned by
  853. * \code PHYSFS_getPrefDir(organization, appName) \endcode, which is
  854. * created if it doesn't exist.
  855. *
  856. * The above is sufficient to make sure your program's configuration directory
  857. * is separated from other clutter, and platform-independent.
  858. *
  859. * The search path will be:
  860. *
  861. * - The Write Dir (created if it doesn't exist)
  862. * - The Base Dir (PHYSFS_getBaseDir())
  863. * - All found CD-ROM dirs (optionally)
  864. *
  865. * These directories are then searched for files ending with the extension
  866. * (archiveExt), which, if they are valid and supported archives, will also
  867. * be added to the search path. If you specified "PKG" for (archiveExt), and
  868. * there's a file named data.PKG in the base dir, it'll be checked. Archives
  869. * can either be appended or prepended to the search path in alphabetical
  870. * order, regardless of which directories they were found in. All archives
  871. * are mounted in the root of the virtual file system ("/").
  872. *
  873. * All of this can be accomplished from the application, but this just does it
  874. * all for you. Feel free to add more to the search path manually, too.
  875. *
  876. * \param organization Name of your company/group/etc to be used as a
  877. * dirname, so keep it small, and no-frills.
  878. *
  879. * \param appName Program-specific name of your program, to separate it
  880. * from other programs using PhysicsFS.
  881. *
  882. * \param archiveExt File extension used by your program to specify an
  883. * archive. For example, Quake 3 uses "pk3", even though
  884. * they are just zipfiles. Specify NULL to not dig out
  885. * archives automatically. Do not specify the '.' char;
  886. * If you want to look for ZIP files, specify "ZIP" and
  887. * not ".ZIP" ... the archive search is case-insensitive.
  888. *
  889. * \param includeCdRoms Non-zero to include CD-ROMs in the search path, and
  890. * (if (archiveExt) != NULL) search them for archives.
  891. * This may cause a significant amount of blocking
  892. * while discs are accessed, and if there are no discs
  893. * in the drive (or even not mounted on Unix systems),
  894. * then they may not be made available anyhow. You may
  895. * want to specify zero and handle the disc setup
  896. * yourself.
  897. *
  898. * \param archivesFirst Non-zero to prepend the archives to the search path.
  899. * Zero to append them. Ignored if !(archiveExt).
  900. *
  901. * \return nonzero on success, zero on error. Specifics of the error can be
  902. * gleaned from PHYSFS_getLastError().
  903. */
  904. PHYSFS_DECL int PHYSFS_setSaneConfig(const char *organization,
  905. const char *appName,
  906. const char *archiveExt,
  907. int includeCdRoms,
  908. int archivesFirst);
  909. /* Directory management stuff ... */
  910. /**
  911. * \fn int PHYSFS_mkdir(const char *dirName)
  912. * \brief Create a directory.
  913. *
  914. * This is specified in platform-independent notation in relation to the
  915. * write dir. All missing parent directories are also created if they
  916. * don't exist.
  917. *
  918. * So if you've got the write dir set to "C:\mygame\writedir" and call
  919. * PHYSFS_mkdir("downloads/maps") then the directories
  920. * "C:\mygame\writedir\downloads" and "C:\mygame\writedir\downloads\maps"
  921. * will be created if possible. If the creation of "maps" fails after we
  922. * have successfully created "downloads", then the function leaves the
  923. * created directory behind and reports failure.
  924. *
  925. * \param dirName New dir to create.
  926. * \return nonzero on success, zero on error. Specifics of the error can be
  927. * gleaned from PHYSFS_getLastError().
  928. *
  929. * \sa PHYSFS_delete
  930. */
  931. PHYSFS_DECL int PHYSFS_mkdir(const char *dirName);
  932. /**
  933. * \fn int PHYSFS_delete(const char *filename)
  934. * \brief Delete a file or directory.
  935. *
  936. * (filename) is specified in platform-independent notation in relation to the
  937. * write dir.
  938. *
  939. * A directory must be empty before this call can delete it.
  940. *
  941. * Deleting a symlink will remove the link, not what it points to, regardless
  942. * of whether you "permitSymLinks" or not.
  943. *
  944. * So if you've got the write dir set to "C:\mygame\writedir" and call
  945. * PHYSFS_delete("downloads/maps/level1.map") then the file
  946. * "C:\mygame\writedir\downloads\maps\level1.map" is removed from the
  947. * physical filesystem, if it exists and the operating system permits the
  948. * deletion.
  949. *
  950. * Note that on Unix systems, deleting a file may be successful, but the
  951. * actual file won't be removed until all processes that have an open
  952. * filehandle to it (including your program) close their handles.
  953. *
  954. * Chances are, the bits that make up the file still exist, they are just
  955. * made available to be written over at a later point. Don't consider this
  956. * a security method or anything. :)
  957. *
  958. * \param filename Filename to delete.
  959. * \return nonzero on success, zero on error. Specifics of the error can be
  960. * gleaned from PHYSFS_getLastError().
  961. */
  962. PHYSFS_DECL int PHYSFS_delete(const char *filename);
  963. /**
  964. * \fn const char *PHYSFS_getRealDir(const char *filename)
  965. * \brief Figure out where in the search path a file resides.
  966. *
  967. * The file is specified in platform-independent notation. The returned
  968. * filename will be the element of the search path where the file was found,
  969. * which may be a directory, or an archive. Even if there are multiple
  970. * matches in different parts of the search path, only the first one found
  971. * is used, just like when opening a file.
  972. *
  973. * So, if you look for "maps/level1.map", and C:\\mygame is in your search
  974. * path and C:\\mygame\\maps\\level1.map exists, then "C:\mygame" is returned.
  975. *
  976. * If a any part of a match is a symbolic link, and you've not explicitly
  977. * permitted symlinks, then it will be ignored, and the search for a match
  978. * will continue.
  979. *
  980. * If you specify a fake directory that only exists as a mount point, it'll
  981. * be associated with the first archive mounted there, even though that
  982. * directory isn't necessarily contained in a real archive.
  983. *
  984. * \warning This will return NULL if there is no real directory associated
  985. * with (filename). Specifically, PHYSFS_mountIo(),
  986. * PHYSFS_mountMemory(), and PHYSFS_mountHandle() will return NULL
  987. * even if the filename is found in the search path. Plan accordingly.
  988. *
  989. * \param filename file to look for.
  990. * \return READ ONLY string of element of search path containing the
  991. * the file in question. NULL if not found.
  992. */
  993. PHYSFS_DECL const char *PHYSFS_getRealDir(const char *filename);
  994. /**
  995. * \fn char **PHYSFS_enumerateFiles(const char *dir)
  996. * \brief Get a file listing of a search path's directory.
  997. *
  998. * Matching directories are interpolated. That is, if "C:\mydir" is in the
  999. * search path and contains a directory "savegames" that contains "x.sav",
  1000. * "y.sav", and "z.sav", and there is also a "C:\userdir" in the search path
  1001. * that has a "savegames" subdirectory with "w.sav", then the following code:
  1002. *
  1003. * \code
  1004. * char **rc = PHYSFS_enumerateFiles("savegames");
  1005. * char **i;
  1006. *
  1007. * for (i = rc; *i != NULL; i++)
  1008. * printf(" * We've got [%s].\n", *i);
  1009. *
  1010. * PHYSFS_freeList(rc);
  1011. * \endcode
  1012. *
  1013. * \...will print:
  1014. *
  1015. * \verbatim
  1016. * We've got [x.sav].
  1017. * We've got [y.sav].
  1018. * We've got [z.sav].
  1019. * We've got [w.sav].\endverbatim
  1020. *
  1021. * Feel free to sort the list however you like. We only promise there will
  1022. * be no duplicates, but not what order the final list will come back in.
  1023. *
  1024. * Don't forget to call PHYSFS_freeList() with the return value from this
  1025. * function when you are done with it.
  1026. *
  1027. * \param dir directory in platform-independent notation to enumerate.
  1028. * \return Null-terminated array of null-terminated strings.
  1029. *
  1030. * \sa PHYSFS_enumerateFilesCallback
  1031. */
  1032. PHYSFS_DECL char **PHYSFS_enumerateFiles(const char *dir);
  1033. /**
  1034. * \fn int PHYSFS_exists(const char *fname)
  1035. * \brief Determine if a file exists in the search path.
  1036. *
  1037. * Reports true if there is an entry anywhere in the search path by the
  1038. * name of (fname).
  1039. *
  1040. * Note that entries that are symlinks are ignored if
  1041. * PHYSFS_permitSymbolicLinks(1) hasn't been called, so you
  1042. * might end up further down in the search path than expected.
  1043. *
  1044. * \param fname filename in platform-independent notation.
  1045. * \return non-zero if filename exists. zero otherwise.
  1046. */
  1047. PHYSFS_DECL int PHYSFS_exists(const char *fname);
  1048. /**
  1049. * \fn int PHYSFS_isDirectory(const char *fname)
  1050. * \brief Determine if a file in the search path is really a directory.
  1051. *
  1052. * \deprecated As of PhysicsFS 2.1, use PHYSFS_stat() instead. This
  1053. * function just wraps it anyhow.
  1054. *
  1055. * Determine if the first occurence of (fname) in the search path is
  1056. * really a directory entry.
  1057. *
  1058. * Note that entries that are symlinks are ignored if
  1059. * PHYSFS_permitSymbolicLinks(1) hasn't been called, so you
  1060. * might end up further down in the search path than expected.
  1061. *
  1062. * \param fname filename in platform-independent notation.
  1063. * \return non-zero if filename exists and is a directory. zero otherwise.
  1064. *
  1065. * \sa PHYSFS_stat
  1066. * \sa PHYSFS_exists
  1067. */
  1068. PHYSFS_DECL int PHYSFS_isDirectory(const char *fname) PHYSFS_DEPRECATED;
  1069. /**
  1070. * \fn int PHYSFS_isSymbolicLink(const char *fname)
  1071. * \brief Determine if a file in the search path is really a symbolic link.
  1072. *
  1073. * \deprecated As of PhysicsFS 2.1, use PHYSFS_stat() instead. This
  1074. * function just wraps it anyhow.
  1075. *
  1076. * Determine if the first occurence of (fname) in the search path is
  1077. * really a symbolic link.
  1078. *
  1079. * Note that entries that are symlinks are ignored if
  1080. * PHYSFS_permitSymbolicLinks(1) hasn't been called, and as such,
  1081. * this function will always return 0 in that case.
  1082. *
  1083. * \param fname filename in platform-independent notation.
  1084. * \return non-zero if filename exists and is a symlink. zero otherwise.
  1085. *
  1086. * \sa PHYSFS_stat
  1087. * \sa PHYSFS_exists
  1088. */
  1089. PHYSFS_DECL int PHYSFS_isSymbolicLink(const char *fname) PHYSFS_DEPRECATED;
  1090. /**
  1091. * \fn PHYSFS_sint64 PHYSFS_getLastModTime(const char *filename)
  1092. * \brief Get the last modification time of a file.
  1093. *
  1094. * \deprecated As of PhysicsFS 2.1, use PHYSFS_stat() instead. This
  1095. * function just wraps it anyhow.
  1096. *
  1097. * The modtime is returned as a number of seconds since the Unix epoch
  1098. * (midnight, Jan 1, 1970). The exact derivation and accuracy of this time
  1099. * depends on the particular archiver. If there is no reasonable way to
  1100. * obtain this information for a particular archiver, or there was some sort
  1101. * of error, this function returns (-1).
  1102. *
  1103. * You must use this and not PHYSFS_stat() if binary compatibility with
  1104. * PhysicsFS 2.0 is important (which it may not be for many people).
  1105. *
  1106. * \param filename filename to check, in platform-independent notation.
  1107. * \return last modified time of the file. -1 if it can't be determined.
  1108. *
  1109. * \sa PHYSFS_stat
  1110. */
  1111. PHYSFS_DECL PHYSFS_sint64 PHYSFS_getLastModTime(const char *filename)
  1112. PHYSFS_DEPRECATED;
  1113. /* i/o stuff... */
  1114. /**
  1115. * \fn PHYSFS_File *PHYSFS_openWrite(const char *filename)
  1116. * \brief Open a file for writing.
  1117. *
  1118. * Open a file for writing, in platform-independent notation and in relation
  1119. * to the write dir as the root of the writable filesystem. The specified
  1120. * file is created if it doesn't exist. If it does exist, it is truncated to
  1121. * zero bytes, and the writing offset is set to the start.
  1122. *
  1123. * Note that entries that are symlinks are ignored if
  1124. * PHYSFS_permitSymbolicLinks(1) hasn't been called, and opening a
  1125. * symlink with this function will fail in such a case.
  1126. *
  1127. * \param filename File to open.
  1128. * \return A valid PhysicsFS filehandle on success, NULL on error. Specifics
  1129. * of the error can be gleaned from PHYSFS_getLastError().
  1130. *
  1131. * \sa PHYSFS_openRead
  1132. * \sa PHYSFS_openAppend
  1133. * \sa PHYSFS_write
  1134. * \sa PHYSFS_close
  1135. */
  1136. PHYSFS_DECL PHYSFS_File *PHYSFS_openWrite(const char *filename);
  1137. /**
  1138. * \fn PHYSFS_File *PHYSFS_openAppend(const char *filename)
  1139. * \brief Open a file for appending.
  1140. *
  1141. * Open a file for writing, in platform-independent notation and in relation
  1142. * to the write dir as the root of the writable filesystem. The specified
  1143. * file is created if it doesn't exist. If it does exist, the writing offset
  1144. * is set to the end of the file, so the first write will be the byte after
  1145. * the end.
  1146. *
  1147. * Note that entries that are symlinks are ignored if
  1148. * PHYSFS_permitSymbolicLinks(1) hasn't been called, and opening a
  1149. * symlink with this function will fail in such a case.
  1150. *
  1151. * \param filename File to open.
  1152. * \return A valid PhysicsFS filehandle on success, NULL on error. Specifics
  1153. * of the error can be gleaned from PHYSFS_getLastError().
  1154. *
  1155. * \sa PHYSFS_openRead
  1156. * \sa PHYSFS_openWrite
  1157. * \sa PHYSFS_write
  1158. * \sa PHYSFS_close
  1159. */
  1160. PHYSFS_DECL PHYSFS_File *PHYSFS_openAppend(const char *filename);
  1161. /**
  1162. * \fn PHYSFS_File *PHYSFS_openRead(const char *filename)
  1163. * \brief Open a file for reading.
  1164. *
  1165. * Open a file for reading, in platform-independent notation. The search path
  1166. * is checked one at a time until a matching file is found, in which case an
  1167. * abstract filehandle is associated with it, and reading may be done.
  1168. * The reading offset is set to the first byte of the file.
  1169. *
  1170. * Note that entries that are symlinks are ignored if
  1171. * PHYSFS_permitSymbolicLinks(1) hasn't been called, and opening a
  1172. * symlink with this function will fail in such a case.
  1173. *
  1174. * \param filename File to open.
  1175. * \return A valid PhysicsFS filehandle on success, NULL on error. Specifics
  1176. * of the error can be gleaned from PHYSFS_getLastError().
  1177. *
  1178. * \sa PHYSFS_openWrite
  1179. * \sa PHYSFS_openAppend
  1180. * \sa PHYSFS_read
  1181. * \sa PHYSFS_close
  1182. */
  1183. PHYSFS_DECL PHYSFS_File *PHYSFS_openRead(const char *filename);
  1184. /**
  1185. * \fn int PHYSFS_close(PHYSFS_File *handle)
  1186. * \brief Close a PhysicsFS filehandle.
  1187. *
  1188. * This call is capable of failing if the operating system was buffering
  1189. * writes to the physical media, and, now forced to write those changes to
  1190. * physical media, can not store the data for some reason. In such a case,
  1191. * the filehandle stays open. A well-written program should ALWAYS check the
  1192. * return value from the close call in addition to every writing call!
  1193. *
  1194. * \param handle handle returned from PHYSFS_open*().
  1195. * \return nonzero on success, zero on error. Specifics of the error can be
  1196. * gleaned from PHYSFS_getLastError().
  1197. *
  1198. * \sa PHYSFS_openRead
  1199. * \sa PHYSFS_openWrite
  1200. * \sa PHYSFS_openAppend
  1201. */
  1202. PHYSFS_DECL int PHYSFS_close(PHYSFS_File *handle);
  1203. /**
  1204. * \fn PHYSFS_sint64 PHYSFS_read(PHYSFS_File *handle, void *buffer, PHYSFS_uint32 objSize, PHYSFS_uint32 objCount)
  1205. * \brief Read data from a PhysicsFS filehandle
  1206. *
  1207. * The file must be opened for reading.
  1208. *
  1209. * \deprecated As of PhysicsFS 2.1, use PHYSFS_readBytes() instead. This
  1210. * function just wraps it anyhow. This function never clarified
  1211. * what would happen if you managed to read a partial object, so
  1212. * working at the byte level makes this cleaner for everyone,
  1213. * especially now that PHYSFS_Io interfaces can be supplied by the
  1214. * application.
  1215. *
  1216. * \param handle handle returned from PHYSFS_openRead().
  1217. * \param buffer buffer to store read data into.
  1218. * \param objSize size in bytes of objects being read from (handle).
  1219. * \param objCount number of (objSize) objects to read from (handle).
  1220. * \return number of objects read. PHYSFS_getLastError() can shed light on
  1221. * the reason this might be < (objCount), as can PHYSFS_eof().
  1222. * -1 if complete failure.
  1223. *
  1224. * \sa PHYSFS_readBytes
  1225. * \sa PHYSFS_eof
  1226. */
  1227. PHYSFS_DECL PHYSFS_sint64 PHYSFS_read(PHYSFS_File *handle,
  1228. void *buffer,
  1229. PHYSFS_uint32 objSize,
  1230. PHYSFS_uint32 objCount)
  1231. PHYSFS_DEPRECATED;
  1232. /**
  1233. * \fn PHYSFS_sint64 PHYSFS_write(PHYSFS_File *handle, const void *buffer, PHYSFS_uint32 objSize, PHYSFS_uint32 objCount)
  1234. * \brief Write data to a PhysicsFS filehandle
  1235. *
  1236. * The file must be opened for writing.
  1237. *
  1238. * \deprecated As of PhysicsFS 2.1, use PHYSFS_writeBytes() instead. This
  1239. * function just wraps it anyhow. This function never clarified
  1240. * what would happen if you managed to write a partial object, so
  1241. * working at the byte level makes this cleaner for everyone,
  1242. * especially now that PHYSFS_Io interfaces can be supplied by the
  1243. * application.
  1244. *
  1245. * \param handle retval from PHYSFS_openWrite() or PHYSFS_openAppend().
  1246. * \param buffer buffer of bytes to write to (handle).
  1247. * \param objSize size in bytes of objects being written to (handle).
  1248. * \param objCount number of (objSize) objects to write to (handle).
  1249. * \return number of objects written. PHYSFS_getLastError() can shed light on
  1250. * the reason this might be < (objCount). -1 if complete failure.
  1251. *
  1252. * \sa PHYSFS_writeBytes
  1253. */
  1254. PHYSFS_DECL PHYSFS_sint64 PHYSFS_write(PHYSFS_File *handle,
  1255. const void *buffer,
  1256. PHYSFS_uint32 objSize,
  1257. PHYSFS_uint32 objCount)
  1258. PHYSFS_DEPRECATED;
  1259. /* File position stuff... */
  1260. /**
  1261. * \fn int PHYSFS_eof(PHYSFS_File *handle)
  1262. * \brief Check for end-of-file state on a PhysicsFS filehandle.
  1263. *
  1264. * Determine if the end of file has been reached in a PhysicsFS filehandle.
  1265. *
  1266. * \param handle handle returned from PHYSFS_openRead().
  1267. * \return nonzero if EOF, zero if not.
  1268. *
  1269. * \sa PHYSFS_read
  1270. * \sa PHYSFS_tell
  1271. */
  1272. PHYSFS_DECL int PHYSFS_eof(PHYSFS_File *handle);
  1273. /**
  1274. * \fn PHYSFS_sint64 PHYSFS_tell(PHYSFS_File *handle)
  1275. * \brief Determine current position within a PhysicsFS filehandle.
  1276. *
  1277. * \param handle handle returned from PHYSFS_open*().
  1278. * \return offset in bytes from start of file. -1 if error occurred.
  1279. * Specifics of the error can be gleaned from PHYSFS_getLastError().
  1280. *
  1281. * \sa PHYSFS_seek
  1282. */
  1283. PHYSFS_DECL PHYSFS_sint64 PHYSFS_tell(PHYSFS_File *handle);
  1284. /**
  1285. * \fn int PHYSFS_seek(PHYSFS_File *handle, PHYSFS_uint64 pos)
  1286. * \brief Seek to a new position within a PhysicsFS filehandle.
  1287. *
  1288. * The next read or write will occur at that place. Seeking past the
  1289. * beginning or end of the file is not allowed, and causes an error.
  1290. *
  1291. * \param handle handle returned from PHYSFS_open*().
  1292. * \param pos number of bytes from start of file to seek to.
  1293. * \return nonzero on success, zero on error. Specifics of the error can be
  1294. * gleaned from PHYSFS_getLastError().
  1295. *
  1296. * \sa PHYSFS_tell
  1297. */
  1298. PHYSFS_DECL int PHYSFS_seek(PHYSFS_File *handle, PHYSFS_uint64 pos);
  1299. /**
  1300. * \fn PHYSFS_sint64 PHYSFS_fileLength(PHYSFS_File *handle)
  1301. * \brief Get total length of a file in bytes.
  1302. *
  1303. * Note that if another process/thread is writing to this file at the same
  1304. * time, then the information this function supplies could be incorrect
  1305. * before you get it. Use with caution, or better yet, don't use at all.
  1306. *
  1307. * \param handle handle returned from PHYSFS_open*().
  1308. * \return size in bytes of the file. -1 if can't be determined.
  1309. *
  1310. * \sa PHYSFS_tell
  1311. * \sa PHYSFS_seek
  1312. */
  1313. PHYSFS_DECL PHYSFS_sint64 PHYSFS_fileLength(PHYSFS_File *handle);
  1314. /* Buffering stuff... */
  1315. /**
  1316. * \fn int PHYSFS_setBuffer(PHYSFS_File *handle, PHYSFS_uint64 bufsize)
  1317. * \brief Set up buffering for a PhysicsFS file handle.
  1318. *
  1319. * Define an i/o buffer for a file handle. A memory block of (bufsize) bytes
  1320. * will be allocated and associated with (handle).
  1321. *
  1322. * For files opened for reading, up to (bufsize) bytes are read from (handle)
  1323. * and stored in the internal buffer. Calls to PHYSFS_read() will pull
  1324. * from this buffer until it is empty, and then refill it for more reading.
  1325. * Note that compressed files, like ZIP archives, will decompress while
  1326. * buffering, so this can be handy for offsetting CPU-intensive operations.
  1327. * The buffer isn't filled until you do your next read.
  1328. *
  1329. * For files opened for writing, data will be buffered to memory until the
  1330. * buffer is full or the buffer is flushed. Closing a handle implicitly
  1331. * causes a flush...check your return values!
  1332. *
  1333. * Seeking, etc transparently accounts for buffering.
  1334. *
  1335. * You can resize an existing buffer by calling this function more than once
  1336. * on the same file. Setting the buffer size to zero will free an existing
  1337. * buffer.
  1338. *
  1339. * PhysicsFS file handles are unbuffered by default.
  1340. *
  1341. * Please check the return value of this function! Failures can include
  1342. * not being able to seek backwards in a read-only file when removing the
  1343. * buffer, not being able to allocate the buffer, and not being able to
  1344. * flush the buffer to disk, among other unexpected problems.
  1345. *
  1346. * \param handle handle returned from PHYSFS_open*().
  1347. * \param bufsize size, in bytes, of buffer to allocate.
  1348. * \return nonzero if successful, zero on error.
  1349. *
  1350. * \sa PHYSFS_flush
  1351. * \sa PHYSFS_read
  1352. * \sa PHYSFS_write
  1353. * \sa PHYSFS_close
  1354. */
  1355. PHYSFS_DECL int PHYSFS_setBuffer(PHYSFS_File *handle, PHYSFS_uint64 bufsize);
  1356. /**
  1357. * \fn int PHYSFS_flush(PHYSFS_File *handle)
  1358. * \brief Flush a buffered PhysicsFS file handle.
  1359. *
  1360. * For buffered files opened for writing, this will put the current contents
  1361. * of the buffer to disk and flag the buffer as empty if possible.
  1362. *
  1363. * For buffered files opened for reading or unbuffered files, this is a safe
  1364. * no-op, and will report success.
  1365. *
  1366. * \param handle handle returned from PHYSFS_open*().
  1367. * \return nonzero if successful, zero on error.
  1368. *
  1369. * \sa PHYSFS_setBuffer
  1370. * \sa PHYSFS_close
  1371. */
  1372. PHYSFS_DECL int PHYSFS_flush(PHYSFS_File *handle);
  1373. /* Byteorder stuff... */
  1374. #ifndef SWIG /* not available from scripting languages. */
  1375. /**
  1376. * \fn PHYSFS_sint16 PHYSFS_swapSLE16(PHYSFS_sint16 val)
  1377. * \brief Swap littleendian signed 16 to platform's native byte order.
  1378. *
  1379. * Take a 16-bit signed value in littleendian format and convert it to
  1380. * the platform's native byte order.
  1381. *
  1382. * \param val value to convert
  1383. * \return converted value.
  1384. */
  1385. PHYSFS_DECL PHYSFS_sint16 PHYSFS_swapSLE16(PHYSFS_sint16 val);
  1386. /**
  1387. * \fn PHYSFS_uint16 PHYSFS_swapULE16(PHYSFS_uint16 val)
  1388. * \brief Swap littleendian unsigned 16 to platform's native byte order.
  1389. *
  1390. * Take a 16-bit unsigned value in littleendian format and convert it to
  1391. * the platform's native byte order.
  1392. *
  1393. * \param val value to convert
  1394. * \return converted value.
  1395. */
  1396. PHYSFS_DECL PHYSFS_uint16 PHYSFS_swapULE16(PHYSFS_uint16 val);
  1397. /**
  1398. * \fn PHYSFS_sint32 PHYSFS_swapSLE32(PHYSFS_sint32 val)
  1399. * \brief Swap littleendian signed 32 to platform's native byte order.
  1400. *
  1401. * Take a 32-bit signed value in littleendian format and convert it to
  1402. * the platform's native byte order.
  1403. *
  1404. * \param val value to convert
  1405. * \return converted value.
  1406. */
  1407. PHYSFS_DECL PHYSFS_sint32 PHYSFS_swapSLE32(PHYSFS_sint32 val);
  1408. /**
  1409. * \fn PHYSFS_uint32 PHYSFS_swapULE32(PHYSFS_uint32 val)
  1410. * \brief Swap littleendian unsigned 32 to platform's native byte order.
  1411. *
  1412. * Take a 32-bit unsigned value in littleendian format and convert it to
  1413. * the platform's native byte order.
  1414. *
  1415. * \param val value to convert
  1416. * \return converted value.
  1417. */
  1418. PHYSFS_DECL PHYSFS_uint32 PHYSFS_swapULE32(PHYSFS_uint32 val);
  1419. /**
  1420. * \fn PHYSFS_sint64 PHYSFS_swapSLE64(PHYSFS_sint64 val)
  1421. * \brief Swap littleendian signed 64 to platform's native byte order.
  1422. *
  1423. * Take a 64-bit signed value in littleendian format and convert it to
  1424. * the platform's native byte order.
  1425. *
  1426. * \param val value to convert
  1427. * \return converted value.
  1428. *
  1429. * \warning Remember, PHYSFS_uint64 is only 32 bits on platforms without
  1430. * any sort of 64-bit support.
  1431. */
  1432. PHYSFS_DECL PHYSFS_sint64 PHYSFS_swapSLE64(PHYSFS_sint64 val);
  1433. /**
  1434. * \fn PHYSFS_uint64 PHYSFS_swapULE64(PHYSFS_uint64 val)
  1435. * \brief Swap littleendian unsigned 64 to platform's native byte order.
  1436. *
  1437. * Take a 64-bit unsigned value in littleendian format and convert it to
  1438. * the platform's native byte order.
  1439. *
  1440. * \param val value to convert
  1441. * \return converted value.
  1442. *
  1443. * \warning Remember, PHYSFS_uint64 is only 32 bits on platforms without
  1444. * any sort of 64-bit support.
  1445. */
  1446. PHYSFS_DECL PHYSFS_uint64 PHYSFS_swapULE64(PHYSFS_uint64 val);
  1447. /**
  1448. * \fn PHYSFS_sint16 PHYSFS_swapSBE16(PHYSFS_sint16 val)
  1449. * \brief Swap bigendian signed 16 to platform's native byte order.
  1450. *
  1451. * Take a 16-bit signed value in bigendian format and convert it to
  1452. * the platform's native byte order.
  1453. *
  1454. * \param val value to convert
  1455. * \return converted value.
  1456. */
  1457. PHYSFS_DECL PHYSFS_sint16 PHYSFS_swapSBE16(PHYSFS_sint16 val);
  1458. /**
  1459. * \fn PHYSFS_uint16 PHYSFS_swapUBE16(PHYSFS_uint16 val)
  1460. * \brief Swap bigendian unsigned 16 to platform's native byte order.
  1461. *
  1462. * Take a 16-bit unsigned value in bigendian format and convert it to
  1463. * the platform's native byte order.
  1464. *
  1465. * \param val value to convert
  1466. * \return converted value.
  1467. */
  1468. PHYSFS_DECL PHYSFS_uint16 PHYSFS_swapUBE16(PHYSFS_uint16 val);
  1469. /**
  1470. * \fn PHYSFS_sint32 PHYSFS_swapSBE32(PHYSFS_sint32 val)
  1471. * \brief Swap bigendian signed 32 to platform's native byte order.
  1472. *
  1473. * Take a 32-bit signed value in bigendian format and convert it to
  1474. * the platform's native byte order.
  1475. *
  1476. * \param val value to convert
  1477. * \return converted value.
  1478. */
  1479. PHYSFS_DECL PHYSFS_sint32 PHYSFS_swapSBE32(PHYSFS_sint32 val);
  1480. /**
  1481. * \fn PHYSFS_uint32 PHYSFS_swapUBE32(PHYSFS_uint32 val)
  1482. * \brief Swap bigendian unsigned 32 to platform's native byte order.
  1483. *
  1484. * Take a 32-bit unsigned value in bigendian format and convert it to
  1485. * the platform's native byte order.
  1486. *
  1487. * \param val value to convert
  1488. * \return converted value.
  1489. */
  1490. PHYSFS_DECL PHYSFS_uint32 PHYSFS_swapUBE32(PHYSFS_uint32 val);
  1491. /**
  1492. * \fn PHYSFS_sint64 PHYSFS_swapSBE64(PHYSFS_sint64 val)
  1493. * \brief Swap bigendian signed 64 to platform's native byte order.
  1494. *
  1495. * Take a 64-bit signed value in bigendian format and convert it to
  1496. * the platform's native byte order.
  1497. *
  1498. * \param val value to convert
  1499. * \return converted value.
  1500. *
  1501. * \warning Remember, PHYSFS_uint64 is only 32 bits on platforms without
  1502. * any sort of 64-bit support.
  1503. */
  1504. PHYSFS_DECL PHYSFS_sint64 PHYSFS_swapSBE64(PHYSFS_sint64 val);
  1505. /**
  1506. * \fn PHYSFS_uint64 PHYSFS_swapUBE64(PHYSFS_uint64 val)
  1507. * \brief Swap bigendian unsigned 64 to platform's native byte order.
  1508. *
  1509. * Take a 64-bit unsigned value in bigendian format and convert it to
  1510. * the platform's native byte order.
  1511. *
  1512. * \param val value to convert
  1513. * \return converted value.
  1514. *
  1515. * \warning Remember, PHYSFS_uint64 is only 32 bits on platforms without
  1516. * any sort of 64-bit support.
  1517. */
  1518. PHYSFS_DECL PHYSFS_uint64 PHYSFS_swapUBE64(PHYSFS_uint64 val);
  1519. #endif /* SWIG */
  1520. /**
  1521. * \fn int PHYSFS_readSLE16(PHYSFS_File *file, PHYSFS_sint16 *val)
  1522. * \brief Read and convert a signed 16-bit littleendian value.
  1523. *
  1524. * Convenience function. Read a signed 16-bit littleendian value from a
  1525. * file and convert it to the platform's native byte order.
  1526. *
  1527. * \param file PhysicsFS file handle from which to read.
  1528. * \param val pointer to where value should be stored.
  1529. * \return zero on failure, non-zero on success. If successful, (*val) will
  1530. * store the result. On failure, you can find out what went wrong
  1531. * from PHYSFS_getLastError().
  1532. */
  1533. PHYSFS_DECL int PHYSFS_readSLE16(PHYSFS_File *file, PHYSFS_sint16 *val);
  1534. /**
  1535. * \fn int PHYSFS_readULE16(PHYSFS_File *file, PHYSFS_uint16 *val)
  1536. * \brief Read and convert an unsigned 16-bit littleendian value.
  1537. *
  1538. * Convenience function. Read an unsigned 16-bit littleendian value from a
  1539. * file and convert it to the platform's native byte order.
  1540. *
  1541. * \param file PhysicsFS file handle from which to read.
  1542. * \param val pointer to where value should be stored.
  1543. * \return zero on failure, non-zero on success. If successful, (*val) will
  1544. * store the result. On failure, you can find out what went wrong
  1545. * from PHYSFS_getLastError().
  1546. *
  1547. */
  1548. PHYSFS_DECL int PHYSFS_readULE16(PHYSFS_File *file, PHYSFS_uint16 *val);
  1549. /**
  1550. * \fn int PHYSFS_readSBE16(PHYSFS_File *file, PHYSFS_sint16 *val)
  1551. * \brief Read and convert a signed 16-bit bigendian value.
  1552. *
  1553. * Convenience function. Read a signed 16-bit bigendian value from a
  1554. * file and convert it to the platform's native byte order.
  1555. *
  1556. * \param file PhysicsFS file handle from which to read.
  1557. * \param val pointer to where value should be stored.
  1558. * \return zero on failure, non-zero on success. If successful, (*val) will
  1559. * store the result. On failure, you can find out what went wrong
  1560. * from PHYSFS_getLastError().
  1561. */
  1562. PHYSFS_DECL int PHYSFS_readSBE16(PHYSFS_File *file, PHYSFS_sint16 *val);
  1563. /**
  1564. * \fn int PHYSFS_readUBE16(PHYSFS_File *file, PHYSFS_uint16 *val)
  1565. * \brief Read and convert an unsigned 16-bit bigendian value.
  1566. *
  1567. * Convenience function. Read an unsigned 16-bit bigendian value from a
  1568. * file and convert it to the platform's native byte order.
  1569. *
  1570. * \param file PhysicsFS file handle from which to read.
  1571. * \param val pointer to where value should be stored.
  1572. * \return zero on failure, non-zero on success. If successful, (*val) will
  1573. * store the result. On failure, you can find out what went wrong
  1574. * from PHYSFS_getLastError().
  1575. *
  1576. */
  1577. PHYSFS_DECL int PHYSFS_readUBE16(PHYSFS_File *file, PHYSFS_uint16 *val);
  1578. /**
  1579. * \fn int PHYSFS_readSLE32(PHYSFS_File *file, PHYSFS_sint32 *val)
  1580. * \brief Read and convert a signed 32-bit littleendian value.
  1581. *
  1582. * Convenience function. Read a signed 32-bit littleendian value from a
  1583. * file and convert it to the platform's native byte order.
  1584. *
  1585. * \param file PhysicsFS file handle from which to read.
  1586. * \param val pointer to where value should be stored.
  1587. * \return zero on failure, non-zero on success. If successful, (*val) will
  1588. * store the result. On failure, you can find out what went wrong
  1589. * from PHYSFS_getLastError().
  1590. */
  1591. PHYSFS_DECL int PHYSFS_readSLE32(PHYSFS_File *file, PHYSFS_sint32 *val);
  1592. /**
  1593. * \fn int PHYSFS_readULE32(PHYSFS_File *file, PHYSFS_uint32 *val)
  1594. * \brief Read and convert an unsigned 32-bit littleendian value.
  1595. *
  1596. * Convenience function. Read an unsigned 32-bit littleendian value from a
  1597. * file and convert it to the platform's native byte order.
  1598. *
  1599. * \param file PhysicsFS file handle from which to read.
  1600. * \param val pointer to where value should be stored.
  1601. * \return zero on failure, non-zero on success. If successful, (*val) will
  1602. * store the result. On failure, you can find out what went wrong
  1603. * from PHYSFS_getLastError().
  1604. *
  1605. */
  1606. PHYSFS_DECL int PHYSFS_readULE32(PHYSFS_File *file, PHYSFS_uint32 *val);
  1607. /**
  1608. * \fn int PHYSFS_readSBE32(PHYSFS_File *file, PHYSFS_sint32 *val)
  1609. * \brief Read and convert a signed 32-bit bigendian value.
  1610. *
  1611. * Convenience function. Read a signed 32-bit bigendian value from a
  1612. * file and convert it to the platform's native byte order.
  1613. *
  1614. * \param file PhysicsFS file handle from which to read.
  1615. * \param val pointer to where value should be stored.
  1616. * \return zero on failure, non-zero on success. If successful, (*val) will
  1617. * store the result. On failure, you can find out what went wrong
  1618. * from PHYSFS_getLastError().
  1619. */
  1620. PHYSFS_DECL int PHYSFS_readSBE32(PHYSFS_File *file, PHYSFS_sint32 *val);
  1621. /**
  1622. * \fn int PHYSFS_readUBE32(PHYSFS_File *file, PHYSFS_uint32 *val)
  1623. * \brief Read and convert an unsigned 32-bit bigendian value.
  1624. *
  1625. * Convenience function. Read an unsigned 32-bit bigendian value from a
  1626. * file and convert it to the platform's native byte order.
  1627. *
  1628. * \param file PhysicsFS file handle from which to read.
  1629. * \param val pointer to where value should be stored.
  1630. * \return zero on failure, non-zero on success. If successful, (*val) will
  1631. * store the result. On failure, you can find out what went wrong
  1632. * from PHYSFS_getLastError().
  1633. *
  1634. */
  1635. PHYSFS_DECL int PHYSFS_readUBE32(PHYSFS_File *file, PHYSFS_uint32 *val);
  1636. /**
  1637. * \fn int PHYSFS_readSLE64(PHYSFS_File *file, PHYSFS_sint64 *val)
  1638. * \brief Read and convert a signed 64-bit littleendian value.
  1639. *
  1640. * Convenience function. Read a signed 64-bit littleendian value from a
  1641. * file and convert it to the platform's native byte order.
  1642. *
  1643. * \param file PhysicsFS file handle from which to read.
  1644. * \param val pointer to where value should be stored.
  1645. * \return zero on failure, non-zero on success. If successful, (*val) will
  1646. * store the result. On failure, you can find out what went wrong
  1647. * from PHYSFS_getLastError().
  1648. *
  1649. * \warning Remember, PHYSFS_sint64 is only 32 bits on platforms without
  1650. * any sort of 64-bit support.
  1651. */
  1652. PHYSFS_DECL int PHYSFS_readSLE64(PHYSFS_File *file, PHYSFS_sint64 *val);
  1653. /**
  1654. * \fn int PHYSFS_readULE64(PHYSFS_File *file, PHYSFS_uint64 *val)
  1655. * \brief Read and convert an unsigned 64-bit littleendian value.
  1656. *
  1657. * Convenience function. Read an unsigned 64-bit littleendian value from a
  1658. * file and convert it to the platform's native byte order.
  1659. *
  1660. * \param file PhysicsFS file handle from which to read.
  1661. * \param val pointer to where value should be stored.
  1662. * \return zero on failure, non-zero on success. If successful, (*val) will
  1663. * store the result. On failure, you can find out what went wrong
  1664. * from PHYSFS_getLastError().
  1665. *
  1666. * \warning Remember, PHYSFS_uint64 is only 32 bits on platforms without
  1667. * any sort of 64-bit support.
  1668. */
  1669. PHYSFS_DECL int PHYSFS_readULE64(PHYSFS_File *file, PHYSFS_uint64 *val);
  1670. /**
  1671. * \fn int PHYSFS_readSBE64(PHYSFS_File *file, PHYSFS_sint64 *val)
  1672. * \brief Read and convert a signed 64-bit bigendian value.
  1673. *
  1674. * Convenience function. Read a signed 64-bit bigendian value from a
  1675. * file and convert it to the platform's native byte order.
  1676. *
  1677. * \param file PhysicsFS file handle from which to read.
  1678. * \param val pointer to where value should be stored.
  1679. * \return zero on failure, non-zero on success. If successful, (*val) will
  1680. * store the result. On failure, you can find out what went wrong
  1681. * from PHYSFS_getLastError().
  1682. *
  1683. * \warning Remember, PHYSFS_sint64 is only 32 bits on platforms without
  1684. * any sort of 64-bit support.
  1685. */
  1686. PHYSFS_DECL int PHYSFS_readSBE64(PHYSFS_File *file, PHYSFS_sint64 *val);
  1687. /**
  1688. * \fn int PHYSFS_readUBE64(PHYSFS_File *file, PHYSFS_uint64 *val)
  1689. * \brief Read and convert an unsigned 64-bit bigendian value.
  1690. *
  1691. * Convenience function. Read an unsigned 64-bit bigendian value from a
  1692. * file and convert it to the platform's native byte order.
  1693. *
  1694. * \param file PhysicsFS file handle from which to read.
  1695. * \param val pointer to where value should be stored.
  1696. * \return zero on failure, non-zero on success. If successful, (*val) will
  1697. * store the result. On failure, you can find out what went wrong
  1698. * from PHYSFS_getLastError().
  1699. *
  1700. * \warning Remember, PHYSFS_uint64 is only 32 bits on platforms without
  1701. * any sort of 64-bit support.
  1702. */
  1703. PHYSFS_DECL int PHYSFS_readUBE64(PHYSFS_File *file, PHYSFS_uint64 *val);
  1704. /**
  1705. * \fn int PHYSFS_writeSLE16(PHYSFS_File *file, PHYSFS_sint16 val)
  1706. * \brief Convert and write a signed 16-bit littleendian value.
  1707. *
  1708. * Convenience function. Convert a signed 16-bit value from the platform's
  1709. * native byte order to littleendian and write it to a file.
  1710. *
  1711. * \param file PhysicsFS file handle to which to write.
  1712. * \param val Value to convert and write.
  1713. * \return zero on failure, non-zero on success. On failure, you can
  1714. * find out what went wrong from PHYSFS_getLastError().
  1715. */
  1716. PHYSFS_DECL int PHYSFS_writeSLE16(PHYSFS_File *file, PHYSFS_sint16 val);
  1717. /**
  1718. * \fn int PHYSFS_writeULE16(PHYSFS_File *file, PHYSFS_uint16 val)
  1719. * \brief Convert and write an unsigned 16-bit littleendian value.
  1720. *
  1721. * Convenience function. Convert an unsigned 16-bit value from the platform's
  1722. * native byte order to littleendian and write it to a file.
  1723. *
  1724. * \param file PhysicsFS file handle to which to write.
  1725. * \param val Value to convert and write.
  1726. * \return zero on failure, non-zero on success. On failure, you can
  1727. * find out what went wrong from PHYSFS_getLastError().
  1728. */
  1729. PHYSFS_DECL int PHYSFS_writeULE16(PHYSFS_File *file, PHYSFS_uint16 val);
  1730. /**
  1731. * \fn int PHYSFS_writeSBE16(PHYSFS_File *file, PHYSFS_sint16 val)
  1732. * \brief Convert and write a signed 16-bit bigendian value.
  1733. *
  1734. * Convenience function. Convert a signed 16-bit value from the platform's
  1735. * native byte order to bigendian and write it to a file.
  1736. *
  1737. * \param file PhysicsFS file handle to which to write.
  1738. * \param val Value to convert and write.
  1739. * \return zero on failure, non-zero on success. On failure, you can
  1740. * find out what went wrong from PHYSFS_getLastError().
  1741. */
  1742. PHYSFS_DECL int PHYSFS_writeSBE16(PHYSFS_File *file, PHYSFS_sint16 val);
  1743. /**
  1744. * \fn int PHYSFS_writeUBE16(PHYSFS_File *file, PHYSFS_uint16 val)
  1745. * \brief Convert and write an unsigned 16-bit bigendian value.
  1746. *
  1747. * Convenience function. Convert an unsigned 16-bit value from the platform's
  1748. * native byte order to bigendian and write it to a file.
  1749. *
  1750. * \param file PhysicsFS file handle to which to write.
  1751. * \param val Value to convert and write.
  1752. * \return zero on failure, non-zero on success. On failure, you can
  1753. * find out what went wrong from PHYSFS_getLastError().
  1754. */
  1755. PHYSFS_DECL int PHYSFS_writeUBE16(PHYSFS_File *file, PHYSFS_uint16 val);
  1756. /**
  1757. * \fn int PHYSFS_writeSLE32(PHYSFS_File *file, PHYSFS_sint32 val)
  1758. * \brief Convert and write a signed 32-bit littleendian value.
  1759. *
  1760. * Convenience function. Convert a signed 32-bit value from the platform's
  1761. * native byte order to littleendian and write it to a file.
  1762. *
  1763. * \param file PhysicsFS file handle to which to write.
  1764. * \param val Value to convert and write.
  1765. * \return zero on failure, non-zero on success. On failure, you can
  1766. * find out what went wrong from PHYSFS_getLastError().
  1767. */
  1768. PHYSFS_DECL int PHYSFS_writeSLE32(PHYSFS_File *file, PHYSFS_sint32 val);
  1769. /**
  1770. * \fn int PHYSFS_writeULE32(PHYSFS_File *file, PHYSFS_uint32 val)
  1771. * \brief Convert and write an unsigned 32-bit littleendian value.
  1772. *
  1773. * Convenience function. Convert an unsigned 32-bit value from the platform's
  1774. * native byte order to littleendian and write it to a file.
  1775. *
  1776. * \param file PhysicsFS file handle to which to write.
  1777. * \param val Value to convert and write.
  1778. * \return zero on failure, non-zero on success. On failure, you can
  1779. * find out what went wrong from PHYSFS_getLastError().
  1780. */
  1781. PHYSFS_DECL int PHYSFS_writeULE32(PHYSFS_File *file, PHYSFS_uint32 val);
  1782. /**
  1783. * \fn int PHYSFS_writeSBE32(PHYSFS_File *file, PHYSFS_sint32 val)
  1784. * \brief Convert and write a signed 32-bit bigendian value.
  1785. *
  1786. * Convenience function. Convert a signed 32-bit value from the platform's
  1787. * native byte order to bigendian and write it to a file.
  1788. *
  1789. * \param file PhysicsFS file handle to which to write.
  1790. * \param val Value to convert and write.
  1791. * \return zero on failure, non-zero on success. On failure, you can
  1792. * find out what went wrong from PHYSFS_getLastError().
  1793. */
  1794. PHYSFS_DECL int PHYSFS_writeSBE32(PHYSFS_File *file, PHYSFS_sint32 val);
  1795. /**
  1796. * \fn int PHYSFS_writeUBE32(PHYSFS_File *file, PHYSFS_uint32 val)
  1797. * \brief Convert and write an unsigned 32-bit bigendian value.
  1798. *
  1799. * Convenience function. Convert an unsigned 32-bit value from the platform's
  1800. * native byte order to bigendian and write it to a file.
  1801. *
  1802. * \param file PhysicsFS file handle to which to write.
  1803. * \param val Value to convert and write.
  1804. * \return zero on failure, non-zero on success. On failure, you can
  1805. * find out what went wrong from PHYSFS_getLastError().
  1806. */
  1807. PHYSFS_DECL int PHYSFS_writeUBE32(PHYSFS_File *file, PHYSFS_uint32 val);
  1808. /**
  1809. * \fn int PHYSFS_writeSLE64(PHYSFS_File *file, PHYSFS_sint64 val)
  1810. * \brief Convert and write a signed 64-bit littleendian value.
  1811. *
  1812. * Convenience function. Convert a signed 64-bit value from the platform's
  1813. * native byte order to littleendian and write it to a file.
  1814. *
  1815. * \param file PhysicsFS file handle to which to write.
  1816. * \param val Value to convert and write.
  1817. * \return zero on failure, non-zero on success. On failure, you can
  1818. * find out what went wrong from PHYSFS_getLastError().
  1819. *
  1820. * \warning Remember, PHYSFS_uint64 is only 32 bits on platforms without
  1821. * any sort of 64-bit support.
  1822. */
  1823. PHYSFS_DECL int PHYSFS_writeSLE64(PHYSFS_File *file, PHYSFS_sint64 val);
  1824. /**
  1825. * \fn int PHYSFS_writeULE64(PHYSFS_File *file, PHYSFS_uint64 val)
  1826. * \brief Convert and write an unsigned 64-bit littleendian value.
  1827. *
  1828. * Convenience function. Convert an unsigned 64-bit value from the platform's
  1829. * native byte order to littleendian and write it to a file.
  1830. *
  1831. * \param file PhysicsFS file handle to which to write.
  1832. * \param val Value to convert and write.
  1833. * \return zero on failure, non-zero on success. On failure, you can
  1834. * find out what went wrong from PHYSFS_getLastError().
  1835. *
  1836. * \warning Remember, PHYSFS_uint64 is only 32 bits on platforms without
  1837. * any sort of 64-bit support.
  1838. */
  1839. PHYSFS_DECL int PHYSFS_writeULE64(PHYSFS_File *file, PHYSFS_uint64 val);
  1840. /**
  1841. * \fn int PHYSFS_writeSBE64(PHYSFS_File *file, PHYSFS_sint64 val)
  1842. * \brief Convert and write a signed 64-bit bigending value.
  1843. *
  1844. * Convenience function. Convert a signed 64-bit value from the platform's
  1845. * native byte order to bigendian and write it to a file.
  1846. *
  1847. * \param file PhysicsFS file handle to which to write.
  1848. * \param val Value to convert and write.
  1849. * \return zero on failure, non-zero on success. On failure, you can
  1850. * find out what went wrong from PHYSFS_getLastError().
  1851. *
  1852. * \warning Remember, PHYSFS_uint64 is only 32 bits on platforms without
  1853. * any sort of 64-bit support.
  1854. */
  1855. PHYSFS_DECL int PHYSFS_writeSBE64(PHYSFS_File *file, PHYSFS_sint64 val);
  1856. /**
  1857. * \fn int PHYSFS_writeUBE64(PHYSFS_File *file, PHYSFS_uint64 val)
  1858. * \brief Convert and write an unsigned 64-bit bigendian value.
  1859. *
  1860. * Convenience function. Convert an unsigned 64-bit value from the platform's
  1861. * native byte order to bigendian and write it to a file.
  1862. *
  1863. * \param file PhysicsFS file handle to which to write.
  1864. * \param val Value to convert and write.
  1865. * \return zero on failure, non-zero on success. On failure, you can
  1866. * find out what went wrong from PHYSFS_getLastError().
  1867. *
  1868. * \warning Remember, PHYSFS_uint64 is only 32 bits on platforms without
  1869. * any sort of 64-bit support.
  1870. */
  1871. PHYSFS_DECL int PHYSFS_writeUBE64(PHYSFS_File *file, PHYSFS_uint64 val);
  1872. /* Everything above this line is part of the PhysicsFS 1.0 API. */
  1873. /**
  1874. * \fn int PHYSFS_isInit(void)
  1875. * \brief Determine if the PhysicsFS library is initialized.
  1876. *
  1877. * Once PHYSFS_init() returns successfully, this will return non-zero.
  1878. * Before a successful PHYSFS_init() and after PHYSFS_deinit() returns
  1879. * successfully, this will return zero. This function is safe to call at
  1880. * any time.
  1881. *
  1882. * \return non-zero if library is initialized, zero if library is not.
  1883. *
  1884. * \sa PHYSFS_init
  1885. * \sa PHYSFS_deinit
  1886. */
  1887. PHYSFS_DECL int PHYSFS_isInit(void);
  1888. /**
  1889. * \fn int PHYSFS_symbolicLinksPermitted(void)
  1890. * \brief Determine if the symbolic links are permitted.
  1891. *
  1892. * This reports the setting from the last call to PHYSFS_permitSymbolicLinks().
  1893. * If PHYSFS_permitSymbolicLinks() hasn't been called since the library was
  1894. * last initialized, symbolic links are implicitly disabled.
  1895. *
  1896. * \return non-zero if symlinks are permitted, zero if not.
  1897. *
  1898. * \sa PHYSFS_permitSymbolicLinks
  1899. */
  1900. PHYSFS_DECL int PHYSFS_symbolicLinksPermitted(void);
  1901. #ifndef SWIG /* not available from scripting languages. */
  1902. /**
  1903. * \struct PHYSFS_Allocator
  1904. * \brief PhysicsFS allocation function pointers.
  1905. *
  1906. * (This is for limited, hardcore use. If you don't immediately see a need
  1907. * for it, you can probably ignore this forever.)
  1908. *
  1909. * You create one of these structures for use with PHYSFS_setAllocator.
  1910. * Allocators are assumed to be reentrant by the caller; please mutex
  1911. * accordingly.
  1912. *
  1913. * Allocations are always discussed in 64-bits, for future expansion...we're
  1914. * on the cusp of a 64-bit transition, and we'll probably be allocating 6
  1915. * gigabytes like it's nothing sooner or later, and I don't want to change
  1916. * this again at that point. If you're on a 32-bit platform and have to
  1917. * downcast, it's okay to return NULL if the allocation is greater than
  1918. * 4 gigabytes, since you'd have to do so anyhow.
  1919. *
  1920. * \sa PHYSFS_setAllocator
  1921. */
  1922. typedef struct PHYSFS_Allocator
  1923. {
  1924. int (*Init)(void); /**< Initialize. Can be NULL. Zero on failure. */
  1925. void (*Deinit)(void); /**< Deinitialize your allocator. Can be NULL. */
  1926. void *(*Malloc)(PHYSFS_uint64); /**< Allocate like malloc(). */
  1927. void *(*Realloc)(void *, PHYSFS_uint64); /**< Reallocate like realloc(). */
  1928. void (*Free)(void *); /**< Free memory from Malloc or Realloc. */
  1929. } PHYSFS_Allocator;
  1930. /**
  1931. * \fn int PHYSFS_setAllocator(const PHYSFS_Allocator *allocator)
  1932. * \brief Hook your own allocation routines into PhysicsFS.
  1933. *
  1934. * (This is for limited, hardcore use. If you don't immediately see a need
  1935. * for it, you can probably ignore this forever.)
  1936. *
  1937. * By default, PhysicsFS will use whatever is reasonable for a platform
  1938. * to manage dynamic memory (usually ANSI C malloc/realloc/free, but
  1939. * some platforms might use something else), but in some uncommon cases, the
  1940. * app might want more control over the library's memory management. This
  1941. * lets you redirect PhysicsFS to use your own allocation routines instead.
  1942. * You can only call this function before PHYSFS_init(); if the library is
  1943. * initialized, it'll reject your efforts to change the allocator mid-stream.
  1944. * You may call this function after PHYSFS_deinit() if you are willing to
  1945. * shut down the library and restart it with a new allocator; this is a safe
  1946. * and supported operation. The allocator remains intact between deinit/init
  1947. * calls. If you want to return to the platform's default allocator, pass a
  1948. * NULL in here.
  1949. *
  1950. * If you aren't immediately sure what to do with this function, you can
  1951. * safely ignore it altogether.
  1952. *
  1953. * \param allocator Structure containing your allocator's entry points.
  1954. * \return zero on failure, non-zero on success. This call only fails
  1955. * when used between PHYSFS_init() and PHYSFS_deinit() calls.
  1956. */
  1957. PHYSFS_DECL int PHYSFS_setAllocator(const PHYSFS_Allocator *allocator);
  1958. #endif /* SWIG */
  1959. /**
  1960. * \fn int PHYSFS_mount(const char *newDir, const char *mountPoint, int appendToPath)
  1961. * \brief Add an archive or directory to the search path.
  1962. *
  1963. * If this is a duplicate, the entry is not added again, even though the
  1964. * function succeeds. You may not add the same archive to two different
  1965. * mountpoints: duplicate checking is done against the archive and not the
  1966. * mountpoint.
  1967. *
  1968. * When you mount an archive, it is added to a virtual file system...all files
  1969. * in all of the archives are interpolated into a single hierachical file
  1970. * tree. Two archives mounted at the same place (or an archive with files
  1971. * overlapping another mountpoint) may have overlapping files: in such a case,
  1972. * the file earliest in the search path is selected, and the other files are
  1973. * inaccessible to the application. This allows archives to be used to
  1974. * override previous revisions; you can use the mounting mechanism to place
  1975. * archives at a specific point in the file tree and prevent overlap; this
  1976. * is useful for downloadable mods that might trample over application data
  1977. * or each other, for example.
  1978. *
  1979. * The mountpoint does not need to exist prior to mounting, which is different
  1980. * than those familiar with the Unix concept of "mounting" may not expect.
  1981. * As well, more than one archive can be mounted to the same mountpoint, or
  1982. * mountpoints and archive contents can overlap...the interpolation mechanism
  1983. * still functions as usual.
  1984. *
  1985. * \param newDir directory or archive to add to the path, in
  1986. * platform-dependent notation.
  1987. * \param mountPoint Location in the interpolated tree that this archive
  1988. * will be "mounted", in platform-independent notation.
  1989. * NULL or "" is equivalent to "/".
  1990. * \param appendToPath nonzero to append to search path, zero to prepend.
  1991. * \return nonzero if added to path, zero on failure (bogus archive, dir
  1992. * missing, etc). Specifics of the error can be
  1993. * gleaned from PHYSFS_getLastError().
  1994. *
  1995. * \sa PHYSFS_removeFromSearchPath
  1996. * \sa PHYSFS_getSearchPath
  1997. * \sa PHYSFS_getMountPoint
  1998. * \sa PHYSFS_mountIo
  1999. */
  2000. PHYSFS_DECL int PHYSFS_mount(const char *newDir,
  2001. const char *mountPoint,
  2002. int appendToPath);
  2003. /**
  2004. * \fn int PHYSFS_getMountPoint(const char *dir)
  2005. * \brief Determine a mounted archive's mountpoint.
  2006. *
  2007. * You give this function the name of an archive or dir you successfully
  2008. * added to the search path, and it reports the location in the interpolated
  2009. * tree where it is mounted. Files mounted with a NULL mountpoint or through
  2010. * PHYSFS_addToSearchPath() will report "/". The return value is READ ONLY
  2011. * and valid until the archive is removed from the search path.
  2012. *
  2013. * \param dir directory or archive previously added to the path, in
  2014. * platform-dependent notation. This must match the string
  2015. * used when adding, even if your string would also reference
  2016. * the same file with a different string of characters.
  2017. * \return READ-ONLY string of mount point if added to path, NULL on failure
  2018. * (bogus archive, etc) Specifics of the error can be gleaned from
  2019. * PHYSFS_getLastError().
  2020. *
  2021. * \sa PHYSFS_removeFromSearchPath
  2022. * \sa PHYSFS_getSearchPath
  2023. * \sa PHYSFS_getMountPoint
  2024. */
  2025. PHYSFS_DECL const char *PHYSFS_getMountPoint(const char *dir);
  2026. #ifndef SWIG /* not available from scripting languages. */
  2027. /**
  2028. * \typedef PHYSFS_StringCallback
  2029. * \brief Function signature for callbacks that report strings.
  2030. *
  2031. * These are used to report a list of strings to an original caller, one
  2032. * string per callback. All strings are UTF-8 encoded. Functions should not
  2033. * try to modify or free the string's memory.
  2034. *
  2035. * These callbacks are used, starting in PhysicsFS 1.1, as an alternative to
  2036. * functions that would return lists that need to be cleaned up with
  2037. * PHYSFS_freeList(). The callback means that the library doesn't need to
  2038. * allocate an entire list and all the strings up front.
  2039. *
  2040. * Be aware that promises data ordering in the list versions are not
  2041. * necessarily so in the callback versions. Check the documentation on
  2042. * specific APIs, but strings may not be sorted as you expect.
  2043. *
  2044. * \param data User-defined data pointer, passed through from the API
  2045. * that eventually called the callback.
  2046. * \param str The string data about which the callback is meant to inform.
  2047. *
  2048. * \sa PHYSFS_getCdRomDirsCallback
  2049. * \sa PHYSFS_getSearchPathCallback
  2050. */
  2051. typedef void (*PHYSFS_StringCallback)(void *data, const char *str);
  2052. /**
  2053. * \typedef PHYSFS_EnumFilesCallback
  2054. * \brief Function signature for callbacks that enumerate files.
  2055. *
  2056. * These are used to report a list of directory entries to an original caller,
  2057. * one file/dir/symlink per callback. All strings are UTF-8 encoded.
  2058. * Functions should not try to modify or free any string's memory.
  2059. *
  2060. * These callbacks are used, starting in PhysicsFS 1.1, as an alternative to
  2061. * functions that would return lists that need to be cleaned up with
  2062. * PHYSFS_freeList(). The callback means that the library doesn't need to
  2063. * allocate an entire list and all the strings up front.
  2064. *
  2065. * Be aware that promises data ordering in the list versions are not
  2066. * necessarily so in the callback versions. Check the documentation on
  2067. * specific APIs, but strings may not be sorted as you expect.
  2068. *
  2069. * \param data User-defined data pointer, passed through from the API
  2070. * that eventually called the callback.
  2071. * \param origdir A string containing the full path, in platform-independent
  2072. * notation, of the directory containing this file. In most
  2073. * cases, this is the directory on which you requested
  2074. * enumeration, passed in the callback for your convenience.
  2075. * \param fname The filename that is being enumerated. It may not be in
  2076. * alphabetical order compared to other callbacks that have
  2077. * fired, and it will not contain the full path. You can
  2078. * recreate the fullpath with $origdir/$fname ... The file
  2079. * can be a subdirectory, a file, a symlink, etc.
  2080. *
  2081. * \sa PHYSFS_enumerateFilesCallback
  2082. */
  2083. typedef void (*PHYSFS_EnumFilesCallback)(void *data, const char *origdir,
  2084. const char *fname);
  2085. /**
  2086. * \fn void PHYSFS_getCdRomDirsCallback(PHYSFS_StringCallback c, void *d)
  2087. * \brief Enumerate CD-ROM directories, using an application-defined callback.
  2088. *
  2089. * Internally, PHYSFS_getCdRomDirs() just calls this function and then builds
  2090. * a list before returning to the application, so functionality is identical
  2091. * except for how the information is represented to the application.
  2092. *
  2093. * Unlike PHYSFS_getCdRomDirs(), this function does not return an array.
  2094. * Rather, it calls a function specified by the application once per
  2095. * detected disc:
  2096. *
  2097. * \code
  2098. *
  2099. * static void foundDisc(void *data, const char *cddir)
  2100. * {
  2101. * printf("cdrom dir [%s] is available.\n", cddir);
  2102. * }
  2103. *
  2104. * // ...
  2105. * PHYSFS_getCdRomDirsCallback(foundDisc, NULL);
  2106. * \endcode
  2107. *
  2108. * This call may block while drives spin up. Be forewarned.
  2109. *
  2110. * \param c Callback function to notify about detected drives.
  2111. * \param d Application-defined data passed to callback. Can be NULL.
  2112. *
  2113. * \sa PHYSFS_StringCallback
  2114. * \sa PHYSFS_getCdRomDirs
  2115. */
  2116. PHYSFS_DECL void PHYSFS_getCdRomDirsCallback(PHYSFS_StringCallback c, void *d);
  2117. /**
  2118. * \fn void PHYSFS_getSearchPathCallback(PHYSFS_StringCallback c, void *d)
  2119. * \brief Enumerate the search path, using an application-defined callback.
  2120. *
  2121. * Internally, PHYSFS_getSearchPath() just calls this function and then builds
  2122. * a list before returning to the application, so functionality is identical
  2123. * except for how the information is represented to the application.
  2124. *
  2125. * Unlike PHYSFS_getSearchPath(), this function does not return an array.
  2126. * Rather, it calls a function specified by the application once per
  2127. * element of the search path:
  2128. *
  2129. * \code
  2130. *
  2131. * static void printSearchPath(void *data, const char *pathItem)
  2132. * {
  2133. * printf("[%s] is in the search path.\n", pathItem);
  2134. * }
  2135. *
  2136. * // ...
  2137. * PHYSFS_getSearchPathCallback(printSearchPath, NULL);
  2138. * \endcode
  2139. *
  2140. * Elements of the search path are reported in order search priority, so the
  2141. * first archive/dir that would be examined when looking for a file is the
  2142. * first element passed through the callback.
  2143. *
  2144. * \param c Callback function to notify about search path elements.
  2145. * \param d Application-defined data passed to callback. Can be NULL.
  2146. *
  2147. * \sa PHYSFS_StringCallback
  2148. * \sa PHYSFS_getSearchPath
  2149. */
  2150. PHYSFS_DECL void PHYSFS_getSearchPathCallback(PHYSFS_StringCallback c, void *d);
  2151. /**
  2152. * \fn void PHYSFS_enumerateFilesCallback(const char *dir, PHYSFS_EnumFilesCallback c, void *d)
  2153. * \brief Get a file listing of a search path's directory, using an application-defined callback.
  2154. *
  2155. * Internally, PHYSFS_enumerateFiles() just calls this function and then builds
  2156. * a list before returning to the application, so functionality is identical
  2157. * except for how the information is represented to the application.
  2158. *
  2159. * Unlike PHYSFS_enumerateFiles(), this function does not return an array.
  2160. * Rather, it calls a function specified by the application once per
  2161. * element of the search path:
  2162. *
  2163. * \code
  2164. *
  2165. * static void printDir(void *data, const char *origdir, const char *fname)
  2166. * {
  2167. * printf(" * We've got [%s] in [%s].\n", fname, origdir);
  2168. * }
  2169. *
  2170. * // ...
  2171. * PHYSFS_enumerateFilesCallback("/some/path", printDir, NULL);
  2172. * \endcode
  2173. *
  2174. * !!! FIXME: enumerateFiles() does not promise alphabetical sorting by
  2175. * !!! FIXME: case-sensitivity in the code, and doesn't promise sorting at
  2176. * !!! FIXME: all in the above docs.
  2177. *
  2178. * Items sent to the callback are not guaranteed to be in any order whatsoever.
  2179. * There is no sorting done at this level, and if you need that, you should
  2180. * probably use PHYSFS_enumerateFiles() instead, which guarantees
  2181. * alphabetical sorting. This form reports whatever is discovered in each
  2182. * archive before moving on to the next. Even within one archive, we can't
  2183. * guarantee what order it will discover data. <em>Any sorting you find in
  2184. * these callbacks is just pure luck. Do not rely on it.</em> As this walks
  2185. * the entire list of archives, you may receive duplicate filenames.
  2186. *
  2187. * \param dir Directory, in platform-independent notation, to enumerate.
  2188. * \param c Callback function to notify about search path elements.
  2189. * \param d Application-defined data passed to callback. Can be NULL.
  2190. *
  2191. * \sa PHYSFS_EnumFilesCallback
  2192. * \sa PHYSFS_enumerateFiles
  2193. */
  2194. PHYSFS_DECL void PHYSFS_enumerateFilesCallback(const char *dir,
  2195. PHYSFS_EnumFilesCallback c,
  2196. void *d);
  2197. /**
  2198. * \fn void PHYSFS_utf8FromUcs4(const PHYSFS_uint32 *src, char *dst, PHYSFS_uint64 len)
  2199. * \brief Convert a UCS-4 string to a UTF-8 string.
  2200. *
  2201. * UCS-4 strings are 32-bits per character: \c wchar_t on Unix.
  2202. *
  2203. * To ensure that the destination buffer is large enough for the conversion,
  2204. * please allocate a buffer that is the same size as the source buffer. UTF-8
  2205. * never uses more than 32-bits per character, so while it may shrink a UCS-4
  2206. * string, it will never expand it.
  2207. *
  2208. * Strings that don't fit in the destination buffer will be truncated, but
  2209. * will always be null-terminated and never have an incomplete UTF-8
  2210. * sequence at the end. If the buffer length is 0, this function does nothing.
  2211. *
  2212. * \param src Null-terminated source string in UCS-4 format.
  2213. * \param dst Buffer to store converted UTF-8 string.
  2214. * \param len Size, in bytes, of destination buffer.
  2215. */
  2216. PHYSFS_DECL void PHYSFS_utf8FromUcs4(const PHYSFS_uint32 *src, char *dst,
  2217. PHYSFS_uint64 len);
  2218. /**
  2219. * \fn void PHYSFS_utf8ToUcs4(const char *src, PHYSFS_uint32 *dst, PHYSFS_uint64 len)
  2220. * \brief Convert a UTF-8 string to a UCS-4 string.
  2221. *
  2222. * UCS-4 strings are 32-bits per character: \c wchar_t on Unix.
  2223. *
  2224. * To ensure that the destination buffer is large enough for the conversion,
  2225. * please allocate a buffer that is four times the size of the source buffer.
  2226. * UTF-8 uses from one to four bytes per character, but UCS-4 always uses
  2227. * four, so an entirely low-ASCII string will quadruple in size!
  2228. *
  2229. * Strings that don't fit in the destination buffer will be truncated, but
  2230. * will always be null-terminated and never have an incomplete UCS-4
  2231. * sequence at the end. If the buffer length is 0, this function does nothing.
  2232. *
  2233. * \param src Null-terminated source string in UTF-8 format.
  2234. * \param dst Buffer to store converted UCS-4 string.
  2235. * \param len Size, in bytes, of destination buffer.
  2236. */
  2237. PHYSFS_DECL void PHYSFS_utf8ToUcs4(const char *src, PHYSFS_uint32 *dst,
  2238. PHYSFS_uint64 len);
  2239. /**
  2240. * \fn void PHYSFS_utf8FromUcs2(const PHYSFS_uint16 *src, char *dst, PHYSFS_uint64 len)
  2241. * \brief Convert a UCS-2 string to a UTF-8 string.
  2242. *
  2243. * \warning you almost certainly should use PHYSFS_utf8FromUtf16(), which
  2244. * became available in PhysicsFS 2.1, unless you know what you're doing.
  2245. *
  2246. * UCS-2 strings are 16-bits per character: \c TCHAR on Windows, when building
  2247. * with Unicode support. Please note that modern versions of Windows use
  2248. * UTF-16, which is an extended form of UCS-2, and not UCS-2 itself. You
  2249. * almost certainly want PHYSFS_utf8FromUtf16() instead.
  2250. *
  2251. * To ensure that the destination buffer is large enough for the conversion,
  2252. * please allocate a buffer that is double the size of the source buffer.
  2253. * UTF-8 never uses more than 32-bits per character, so while it may shrink
  2254. * a UCS-2 string, it may also expand it.
  2255. *
  2256. * Strings that don't fit in the destination buffer will be truncated, but
  2257. * will always be null-terminated and never have an incomplete UTF-8
  2258. * sequence at the end. If the buffer length is 0, this function does nothing.
  2259. *
  2260. * \param src Null-terminated source string in UCS-2 format.
  2261. * \param dst Buffer to store converted UTF-8 string.
  2262. * \param len Size, in bytes, of destination buffer.
  2263. *
  2264. * \sa PHYSFS_utf8FromUtf16
  2265. */
  2266. PHYSFS_DECL void PHYSFS_utf8FromUcs2(const PHYSFS_uint16 *src, char *dst,
  2267. PHYSFS_uint64 len);
  2268. /**
  2269. * \fn PHYSFS_utf8ToUcs2(const char *src, PHYSFS_uint16 *dst, PHYSFS_uint64 len)
  2270. * \brief Convert a UTF-8 string to a UCS-2 string.
  2271. *
  2272. * \warning you almost certainly should use PHYSFS_utf8ToUtf16(), which
  2273. * became available in PhysicsFS 2.1, unless you know what you're doing.
  2274. *
  2275. * UCS-2 strings are 16-bits per character: \c TCHAR on Windows, when building
  2276. * with Unicode support. Please note that modern versions of Windows use
  2277. * UTF-16, which is an extended form of UCS-2, and not UCS-2 itself. You
  2278. * almost certainly want PHYSFS_utf8ToUtf16() instead, but you need to
  2279. * understand how that changes things, too.
  2280. *
  2281. * To ensure that the destination buffer is large enough for the conversion,
  2282. * please allocate a buffer that is double the size of the source buffer.
  2283. * UTF-8 uses from one to four bytes per character, but UCS-2 always uses
  2284. * two, so an entirely low-ASCII string will double in size!
  2285. *
  2286. * Strings that don't fit in the destination buffer will be truncated, but
  2287. * will always be null-terminated and never have an incomplete UCS-2
  2288. * sequence at the end. If the buffer length is 0, this function does nothing.
  2289. *
  2290. * \param src Null-terminated source string in UTF-8 format.
  2291. * \param dst Buffer to store converted UCS-2 string.
  2292. * \param len Size, in bytes, of destination buffer.
  2293. *
  2294. * \sa PHYSFS_utf8ToUtf16
  2295. */
  2296. PHYSFS_DECL void PHYSFS_utf8ToUcs2(const char *src, PHYSFS_uint16 *dst,
  2297. PHYSFS_uint64 len);
  2298. /**
  2299. * \fn void PHYSFS_utf8FromLatin1(const char *src, char *dst, PHYSFS_uint64 len)
  2300. * \brief Convert a UTF-8 string to a Latin1 string.
  2301. *
  2302. * Latin1 strings are 8-bits per character: a popular "high ASCII" encoding.
  2303. *
  2304. * To ensure that the destination buffer is large enough for the conversion,
  2305. * please allocate a buffer that is double the size of the source buffer.
  2306. * UTF-8 expands latin1 codepoints over 127 from 1 to 2 bytes, so the string
  2307. * may grow in some cases.
  2308. *
  2309. * Strings that don't fit in the destination buffer will be truncated, but
  2310. * will always be null-terminated and never have an incomplete UTF-8
  2311. * sequence at the end. If the buffer length is 0, this function does nothing.
  2312. *
  2313. * Please note that we do not supply a UTF-8 to Latin1 converter, since Latin1
  2314. * can't express most Unicode codepoints. It's a legacy encoding; you should
  2315. * be converting away from it at all times.
  2316. *
  2317. * \param src Null-terminated source string in Latin1 format.
  2318. * \param dst Buffer to store converted UTF-8 string.
  2319. * \param len Size, in bytes, of destination buffer.
  2320. */
  2321. PHYSFS_DECL void PHYSFS_utf8FromLatin1(const char *src, char *dst,
  2322. PHYSFS_uint64 len);
  2323. /* Everything above this line is part of the PhysicsFS 2.0 API. */
  2324. /**
  2325. * \fn int PHYSFS_unmount(const char *oldDir)
  2326. * \brief Remove a directory or archive from the search path.
  2327. *
  2328. * This is functionally equivalent to PHYSFS_removeFromSearchPath(), but that
  2329. * function is deprecated to keep the vocabulary paired with PHYSFS_mount().
  2330. *
  2331. * This must be a (case-sensitive) match to a dir or archive already in the
  2332. * search path, specified in platform-dependent notation.
  2333. *
  2334. * This call will fail (and fail to remove from the path) if the element still
  2335. * has files open in it.
  2336. *
  2337. * \param oldDir dir/archive to remove.
  2338. * \return nonzero on success, zero on failure.
  2339. * Specifics of the error can be gleaned from PHYSFS_getLastError().
  2340. *
  2341. * \sa PHYSFS_getSearchPath
  2342. * \sa PHYSFS_mount
  2343. */
  2344. PHYSFS_DECL int PHYSFS_unmount(const char *oldDir);
  2345. /**
  2346. * \fn const PHYSFS_Allocator *PHYSFS_getAllocator(void)
  2347. * \brief Discover the current allocator.
  2348. *
  2349. * (This is for limited, hardcore use. If you don't immediately see a need
  2350. * for it, you can probably ignore this forever.)
  2351. *
  2352. * This function exposes the function pointers that make up the currently used
  2353. * allocator. This can be useful for apps that want to access PhysicsFS's
  2354. * internal, default allocation routines, as well as for external code that
  2355. * wants to share the same allocator, even if the application specified their
  2356. * own.
  2357. *
  2358. * This call is only valid between PHYSFS_init() and PHYSFS_deinit() calls;
  2359. * it will return NULL if the library isn't initialized. As we can't
  2360. * guarantee the state of the internal allocators unless the library is
  2361. * initialized, you shouldn't use any allocator returned here after a call
  2362. * to PHYSFS_deinit().
  2363. *
  2364. * Do not call the returned allocator's Init() or Deinit() methods under any
  2365. * circumstances.
  2366. *
  2367. * If you aren't immediately sure what to do with this function, you can
  2368. * safely ignore it altogether.
  2369. *
  2370. * \return Current allocator, as set by PHYSFS_setAllocator(), or PhysicsFS's
  2371. * internal, default allocator if no application defined allocator
  2372. * is currently set. Will return NULL if the library is not
  2373. * initialized.
  2374. *
  2375. * \sa PHYSFS_Allocator
  2376. * \sa PHYSFS_setAllocator
  2377. */
  2378. PHYSFS_DECL const PHYSFS_Allocator *PHYSFS_getAllocator(void);
  2379. #endif /* SWIG */
  2380. /**
  2381. * \enum PHYSFS_FileType
  2382. * \brief Type of a File
  2383. *
  2384. * Possible types of a file.
  2385. *
  2386. * \sa PHYSFS_stat
  2387. */
  2388. typedef enum PHYSFS_FileType
  2389. {
  2390. PHYSFS_FILETYPE_REGULAR, /**< a normal file */
  2391. PHYSFS_FILETYPE_DIRECTORY, /**< a directory */
  2392. PHYSFS_FILETYPE_SYMLINK, /**< a symlink */
  2393. PHYSFS_FILETYPE_OTHER /**< something completely different like a device */
  2394. } PHYSFS_FileType;
  2395. /**
  2396. * \struct PHYSFS_Stat
  2397. * \brief Meta data for a file or directory
  2398. *
  2399. * Container for various meta data about a file in the virtual file system.
  2400. * PHYSFS_stat() uses this structure for returning the information. The time
  2401. * data will be either the number of seconds since the Unix epoch (midnight,
  2402. * Jan 1, 1970), or -1 if the information isn't available or applicable.
  2403. * The (filesize) field is measured in bytes.
  2404. * The (readonly) field tells you whether when you open a file for writing you
  2405. * are writing to the same file as if you were opening it, given you have
  2406. * enough filesystem rights to do that. !!! FIXME: this might change.
  2407. *
  2408. * \sa PHYSFS_stat
  2409. * \sa PHYSFS_FileType
  2410. */
  2411. typedef struct PHYSFS_Stat
  2412. {
  2413. PHYSFS_sint64 filesize; /**< size in bytes, -1 for non-files and unknown */
  2414. PHYSFS_sint64 modtime; /**< last modification time */
  2415. PHYSFS_sint64 createtime; /**< like modtime, but for file creation time */
  2416. PHYSFS_sint64 accesstime; /**< like modtime, but for file access time */
  2417. PHYSFS_FileType filetype; /**< File? Directory? Symlink? */
  2418. int readonly; /**< non-zero if read only, zero if writable. */
  2419. } PHYSFS_Stat;
  2420. /**
  2421. * \fn int PHYSFS_stat(const char *fname, PHYSFS_Stat *stat)
  2422. * \brief Get various information about a directory or a file.
  2423. *
  2424. * Obtain various information about a file or directory from the meta data.
  2425. *
  2426. * This function will never follow symbolic links. If you haven't enabled
  2427. * symlinks with PHYSFS_permitSymbolicLinks(), stat'ing a symlink will be
  2428. * treated like stat'ing a non-existant file. If symlinks are enabled,
  2429. * stat'ing a symlink will give you information on the link itself and not
  2430. * what it points to.
  2431. *
  2432. * \param fname filename to check, in platform-indepedent notation.
  2433. * \param stat pointer to structure to fill in with data about (fname).
  2434. * \return non-zero on success, zero on failure. On failure, (stat)'s
  2435. * contents are undefined.
  2436. *
  2437. * \sa PHYSFS_Stat
  2438. */
  2439. PHYSFS_DECL int PHYSFS_stat(const char *fname, PHYSFS_Stat *stat);
  2440. #ifndef SWIG /* not available from scripting languages. */
  2441. /**
  2442. * \fn void PHYSFS_utf8FromUtf16(const PHYSFS_uint16 *src, char *dst, PHYSFS_uint64 len)
  2443. * \brief Convert a UTF-16 string to a UTF-8 string.
  2444. *
  2445. * UTF-16 strings are 16-bits per character (except some chars, which are
  2446. * 32-bits): \c TCHAR on Windows, when building with Unicode support. Modern
  2447. * Windows releases use UTF-16. Windows releases before 2000 used TCHAR, but
  2448. * only handled UCS-2. UTF-16 _is_ UCS-2, except for the characters that
  2449. * are 4 bytes, which aren't representable in UCS-2 at all anyhow. If you
  2450. * aren't sure, you should be using UTF-16 at this point on Windows.
  2451. *
  2452. * To ensure that the destination buffer is large enough for the conversion,
  2453. * please allocate a buffer that is double the size of the source buffer.
  2454. * UTF-8 never uses more than 32-bits per character, so while it may shrink
  2455. * a UTF-16 string, it may also expand it.
  2456. *
  2457. * Strings that don't fit in the destination buffer will be truncated, but
  2458. * will always be null-terminated and never have an incomplete UTF-8
  2459. * sequence at the end. If the buffer length is 0, this function does nothing.
  2460. *
  2461. * \param src Null-terminated source string in UTF-16 format.
  2462. * \param dst Buffer to store converted UTF-8 string.
  2463. * \param len Size, in bytes, of destination buffer.
  2464. */
  2465. PHYSFS_DECL void PHYSFS_utf8FromUtf16(const PHYSFS_uint16 *src, char *dst,
  2466. PHYSFS_uint64 len);
  2467. /**
  2468. * \fn PHYSFS_utf8ToUtf16(const char *src, PHYSFS_uint16 *dst, PHYSFS_uint64 len)
  2469. * \brief Convert a UTF-8 string to a UTF-16 string.
  2470. *
  2471. * UTF-16 strings are 16-bits per character (except some chars, which are
  2472. * 32-bits): \c TCHAR on Windows, when building with Unicode support. Modern
  2473. * Windows releases use UTF-16. Windows releases before 2000 used TCHAR, but
  2474. * only handled UCS-2. UTF-16 _is_ UCS-2, except for the characters that
  2475. * are 4 bytes, which aren't representable in UCS-2 at all anyhow. If you
  2476. * aren't sure, you should be using UTF-16 at this point on Windows.
  2477. *
  2478. * To ensure that the destination buffer is large enough for the conversion,
  2479. * please allocate a buffer that is double the size of the source buffer.
  2480. * UTF-8 uses from one to four bytes per character, but UTF-16 always uses
  2481. * two to four, so an entirely low-ASCII string will double in size! The
  2482. * UTF-16 characters that would take four bytes also take four bytes in UTF-8,
  2483. * so you don't need to allocate 4x the space just in case: double will do.
  2484. *
  2485. * Strings that don't fit in the destination buffer will be truncated, but
  2486. * will always be null-terminated and never have an incomplete UTF-16
  2487. * surrogate pair at the end. If the buffer length is 0, this function does
  2488. * nothing.
  2489. *
  2490. * \param src Null-terminated source string in UTF-8 format.
  2491. * \param dst Buffer to store converted UTF-16 string.
  2492. * \param len Size, in bytes, of destination buffer.
  2493. *
  2494. * \sa PHYSFS_utf8ToUtf16
  2495. */
  2496. PHYSFS_DECL void PHYSFS_utf8ToUtf16(const char *src, PHYSFS_uint16 *dst,
  2497. PHYSFS_uint64 len);
  2498. #endif /* SWIG */
  2499. /**
  2500. * \fn PHYSFS_sint64 PHYSFS_readBytes(PHYSFS_File *handle, void *buffer, PHYSFS_uint64 len)
  2501. * \brief Read bytes from a PhysicsFS filehandle
  2502. *
  2503. * The file must be opened for reading.
  2504. *
  2505. * \param handle handle returned from PHYSFS_openRead().
  2506. * \param buffer buffer of at least (len) bytes to store read data into.
  2507. * \param len number of bytes being read from (handle).
  2508. * \return number of bytes read. This may be less than (len); this does not
  2509. * signify an error, necessarily (a short read may mean EOF).
  2510. * PHYSFS_getLastError() can shed light on the reason this might
  2511. * be < (len), as can PHYSFS_eof(). -1 if complete failure.
  2512. *
  2513. * \sa PHYSFS_eof
  2514. */
  2515. PHYSFS_DECL PHYSFS_sint64 PHYSFS_readBytes(PHYSFS_File *handle, void *buffer,
  2516. PHYSFS_uint64 len);
  2517. /**
  2518. * \fn PHYSFS_sint64 PHYSFS_writeBytes(PHYSFS_File *handle, const void *buffer, PHYSFS_uint64 len)
  2519. * \brief Write data to a PhysicsFS filehandle
  2520. *
  2521. * The file must be opened for writing.
  2522. *
  2523. * Please note that while (len) is an unsigned 64-bit integer, you are limited
  2524. * to 63 bits (9223372036854775807 bytes), so we can return a negative value
  2525. * on error. If length is greater than 0x7FFFFFFFFFFFFFFF, this function will
  2526. * immediately fail. For systems without a 64-bit datatype, you are limited
  2527. * to 31 bits (0x7FFFFFFF, or 2147483647 bytes). We trust most things won't
  2528. * need to do multiple gigabytes of i/o in one call anyhow, but why limit
  2529. * things?
  2530. *
  2531. * \param handle retval from PHYSFS_openWrite() or PHYSFS_openAppend().
  2532. * \param buffer buffer of (len) bytes to write to (handle).
  2533. * \param len number of bytes being written to (handle).
  2534. * \return number of bytes written. This may be less than (len); in the case
  2535. * of an error, the system may try to write as many bytes as possible,
  2536. * so an incomplete write might occur. PHYSFS_getLastError() can shed
  2537. * light on the reason this might be < (len). -1 if complete failure.
  2538. */
  2539. PHYSFS_DECL PHYSFS_sint64 PHYSFS_writeBytes(PHYSFS_File *handle,
  2540. const void *buffer,
  2541. PHYSFS_uint64 len);
  2542. #ifndef SWIG /* not available from scripting languages. */
  2543. /**
  2544. * \struct PHYSFS_Io
  2545. * \brief An abstract i/o interface.
  2546. *
  2547. * \warning This is advanced, hardcore stuff. You don't need this unless you
  2548. * really know what you're doing. Most apps will not need this.
  2549. *
  2550. * Historically, PhysicsFS provided access to the physical filesystem and
  2551. * archives within that filesystem. However, sometimes you need more power
  2552. * than this. Perhaps you need to provide an archive that is entirely
  2553. * contained in RAM, or you need to bridge some other file i/o API to
  2554. * PhysicsFS, or you need to translate the bits (perhaps you have a
  2555. * a standard .zip file that's encrypted, and you need to decrypt on the fly
  2556. * for the unsuspecting zip archiver).
  2557. *
  2558. * A PHYSFS_Io is the interface that Archivers use to get archive data.
  2559. * Historically, this has mapped to file i/o to the physical filesystem, but
  2560. * as of PhysicsFS 2.1, applications can provide their own i/o implementations
  2561. * at runtime.
  2562. *
  2563. * This interface isn't necessarily a good universal fit for i/o. There are a
  2564. * few requirements of note:
  2565. *
  2566. * - They only do blocking i/o (at least, for now).
  2567. * - They need to be able to duplicate. If you have a file handle from
  2568. * fopen(), you need to be able to create a unique clone of it (so we
  2569. * have two handles to the same file that can both seek/read/etc without
  2570. * stepping on each other).
  2571. * - They need to know the size of their entire data set.
  2572. * - They need to be able to seek and rewind on demand.
  2573. *
  2574. * ...in short, you're probably not going to write an HTTP implementation.
  2575. *
  2576. * Thread safety: TO BE DECIDED. !!! FIXME
  2577. *
  2578. * \sa PHYSFS_mountIo
  2579. */
  2580. typedef struct PHYSFS_Io
  2581. {
  2582. /**
  2583. * \brief Binary compatibility information.
  2584. *
  2585. * This must be set to zero at this time. Future versions of this
  2586. * struct will increment this field, so we know what a given
  2587. * implementation supports. We'll presumably keep supporting older
  2588. * versions as we offer new features, though.
  2589. */
  2590. PHYSFS_uint32 version;
  2591. /**
  2592. * \brief Instance data for this struct.
  2593. *
  2594. * Each instance has a pointer associated with it that can be used to
  2595. * store anything it likes. This pointer is per-instance of the stream,
  2596. * so presumably it will change when calling duplicate(). This can be
  2597. * deallocated during the destroy() method.
  2598. */
  2599. void *opaque;
  2600. /**
  2601. * \brief Read more data.
  2602. *
  2603. * Read (len) bytes from the interface, at the current i/o position, and
  2604. * store them in (buffer). The current i/o position should move ahead
  2605. * by the number of bytes successfully read.
  2606. *
  2607. * You don't have to implement this; set it to NULL if not implemented.
  2608. * This will only be used if the file is opened for reading. If set to
  2609. * NULL, a default implementation that immediately reports failure will
  2610. * be used.
  2611. *
  2612. * \param io The i/o instance to read from.
  2613. * \param buf The buffer to store data into. It must be at least
  2614. * (len) bytes long and can't be NULL.
  2615. * \param len The number of bytes to read from the interface.
  2616. * \return number of bytes read from file, 0 on EOF, -1 if complete
  2617. * failure.
  2618. */
  2619. PHYSFS_sint64 (*read)(struct PHYSFS_Io *io, void *buf, PHYSFS_uint64 len);
  2620. /**
  2621. * \brief Write more data.
  2622. *
  2623. * Write (len) bytes from (buffer) to the interface at the current i/o
  2624. * position. The current i/o position should move ahead by the number of
  2625. * bytes successfully written.
  2626. *
  2627. * You don't have to implement this; set it to NULL if not implemented.
  2628. * This will only be used if the file is opened for writing. If set to
  2629. * NULL, a default implementation that immediately reports failure will
  2630. * be used.
  2631. *
  2632. * You are allowed to buffer; a write can succeed here and then later
  2633. * fail when flushing. Note that PHYSFS_setBuffer() may be operating a
  2634. * level above your i/o, so you should usually not implement your
  2635. * own buffering routines.
  2636. *
  2637. * \param io The i/o instance to write to.
  2638. * \param buffer The buffer to read data from. It must be at least
  2639. * (len) bytes long and can't be NULL.
  2640. * \param len The number of bytes to read from (buffer).
  2641. * \return number of bytes written to file, -1 if complete failure.
  2642. */
  2643. PHYSFS_sint64 (*write)(struct PHYSFS_Io *io, const void *buffer,
  2644. PHYSFS_uint64 len);
  2645. /**
  2646. * \brief Move i/o position to a given byte offset from start.
  2647. *
  2648. * This method moves the i/o position, so the next read/write will
  2649. * be of the byte at (offset) offset. Seeks past the end of file should
  2650. * be treated as an error condition.
  2651. *
  2652. * \param io The i/o instance to seek.
  2653. * \param offset The new byte offset for the i/o position.
  2654. * \return non-zero on success, zero on error.
  2655. */
  2656. int (*seek)(struct PHYSFS_Io *io, PHYSFS_uint64 offset);
  2657. /**
  2658. * \brief Report current i/o position.
  2659. *
  2660. * Return bytes offset, or -1 if you aren't able to determine. A failure
  2661. * will almost certainly be fatal to further use of this stream, so you
  2662. * may not leave this unimplemented.
  2663. *
  2664. * \param io The i/o instance to query.
  2665. * \return The current byte offset for the i/o position, -1 if unknown.
  2666. */
  2667. PHYSFS_sint64 (*tell)(struct PHYSFS_Io *io);
  2668. /**
  2669. * \brief Determine size of the i/o instance's dataset.
  2670. *
  2671. * Return number of bytes available in the file, or -1 if you
  2672. * aren't able to determine. A failure will almost certainly be fatal
  2673. * to further use of this stream, so you may not leave this unimplemented.
  2674. *
  2675. * \param io The i/o instance to query.
  2676. * \return Total size, in bytes, of the dataset.
  2677. */
  2678. PHYSFS_sint64 (*length)(struct PHYSFS_Io *io);
  2679. /**
  2680. * \brief Duplicate this i/o instance.
  2681. *
  2682. * // !!! FIXME: write me.
  2683. *
  2684. * \param io The i/o instance to duplicate.
  2685. * \return A new value for a stream's (opaque) field, or NULL on error.
  2686. */
  2687. struct PHYSFS_Io *(*duplicate)(struct PHYSFS_Io *io);
  2688. /**
  2689. * \brief Flush resources to media, or wherever.
  2690. *
  2691. * This is the chance to report failure for writes that had claimed
  2692. * success earlier, but still had a chance to actually fail. This method
  2693. * can be NULL if flushing isn't necessary.
  2694. *
  2695. * This function may be called before destroy(), as it can report failure
  2696. * and destroy() can not. It may be called at other times, too.
  2697. *
  2698. * \param io The i/o instance to flush.
  2699. * \return Zero on error, non-zero on success.
  2700. */
  2701. int (*flush)(struct PHYSFS_Io *io);
  2702. /**
  2703. * \brief Cleanup and deallocate i/o instance.
  2704. *
  2705. * Free associated resources, including (opaque) if applicable.
  2706. *
  2707. * This function must always succeed: as such, it returns void. The
  2708. * system may call your flush() method before this. You may report
  2709. * failure there if necessary. This method may still be called if
  2710. * flush() fails, in which case you'll have to abandon unflushed data
  2711. * and other failing conditions and clean up.
  2712. *
  2713. * Once this method is called for a given instance, the system will assume
  2714. * it is unsafe to touch that instance again and will discard any
  2715. * references to it.
  2716. *
  2717. * \param s The i/o instance to destroy.
  2718. */
  2719. void (*destroy)(struct PHYSFS_Io *io);
  2720. } PHYSFS_Io;
  2721. /**
  2722. * \fn int PHYSFS_mountIo(PHYSFS_Io *io, const char *fname, const char *mountPoint, int appendToPath)
  2723. * \brief Add an archive, built on a PHYSFS_Io, to the search path.
  2724. *
  2725. * \warning Unless you have some special, low-level need, you should be using
  2726. * PHYSFS_mount() instead of this.
  2727. *
  2728. * This function operates just like PHYSFS_mount(), but takes a PHYSFS_Io
  2729. * instead of a pathname. Behind the scenes, PHYSFS_mount() calls this
  2730. * function with a physical-filesystem-based PHYSFS_Io.
  2731. *
  2732. * (filename) is only used here to optimize archiver selection (if you name it
  2733. * XXXXX.zip, we might try the ZIP archiver first, for example). It doesn't
  2734. * need to refer to a real file at all, and can even be NULL. If the filename
  2735. * isn't helpful, the system will try every archiver until one works or none
  2736. * of them do.
  2737. *
  2738. * (io) must remain until the archive is unmounted. When the archive is
  2739. * unmounted, the system will call (io)->destroy(io), which will give you
  2740. * a chance to free your resources.
  2741. *
  2742. * If this function fails, (io)->destroy(io) is not called.
  2743. *
  2744. * \param io i/o instance for archive to add to the path.
  2745. * \param fname Filename that can represent this stream. Can be NULL.
  2746. * \param mountPoint Location in the interpolated tree that this archive
  2747. * will be "mounted", in platform-independent notation.
  2748. * NULL or "" is equivalent to "/".
  2749. * \param appendToPath nonzero to append to search path, zero to prepend.
  2750. * \return nonzero if added to path, zero on failure (bogus archive, stream
  2751. * i/o issue, etc). Specifics of the error can be
  2752. * gleaned from PHYSFS_getLastError().
  2753. *
  2754. * \sa PHYSFS_unmount
  2755. * \sa PHYSFS_getSearchPath
  2756. * \sa PHYSFS_getMountPoint
  2757. */
  2758. PHYSFS_DECL int PHYSFS_mountIo(PHYSFS_Io *io, const char *fname,
  2759. const char *mountPoint, int appendToPath);
  2760. #endif /* SWIG */
  2761. /**
  2762. * \fn int PHYSFS_mountMemory(const void *ptr, PHYSFS_uint64 len, void (*del)(void *), const char *fname, const char *mountPoint, int appendToPath)
  2763. * \brief Add an archive, contained in a memory buffer, to the search path.
  2764. *
  2765. * \warning Unless you have some special, low-level need, you should be using
  2766. * PHYSFS_mount() instead of this.
  2767. *
  2768. * This function operates just like PHYSFS_mount(), but takes a memory buffer
  2769. * instead of a pathname. This buffer contains all the data of the archive,
  2770. * and is used instead of a real file in the physical filesystem.
  2771. *
  2772. * (filename) is only used here to optimize archiver selection (if you name it
  2773. * XXXXX.zip, we might try the ZIP archiver first, for example). It doesn't
  2774. * need to refer to a real file at all, and can even be NULL. If the filename
  2775. * isn't helpful, the system will try every archiver until one works or none
  2776. * of them do.
  2777. *
  2778. * (ptr) must remain until the archive is unmounted. When the archive is
  2779. * unmounted, the system will call (del)(ptr), which will notify you that
  2780. * the system is done with the buffer, and give you a chance to free your
  2781. * resources. (del) can be NULL, in which case the system will make no
  2782. * attempt to free the buffer.
  2783. *
  2784. * If this function fails, (del) is not called.
  2785. *
  2786. * \param ptr Address of the memory buffer containing the archive data.
  2787. * \param len Size of memory buffer, in bytes.
  2788. * \param del A callback that triggers upon unmount. Can be NULL.
  2789. * \param fname Filename that can represent this stream. Can be NULL.
  2790. * \param mountPoint Location in the interpolated tree that this archive
  2791. * will be "mounted", in platform-independent notation.
  2792. * NULL or "" is equivalent to "/".
  2793. * \param appendToPath nonzero to append to search path, zero to prepend.
  2794. * \return nonzero if added to path, zero on failure (bogus archive, etc).
  2795. * Specifics of the error can be gleaned from
  2796. * PHYSFS_getLastError().
  2797. *
  2798. * \sa PHYSFS_unmount
  2799. * \sa PHYSFS_getSearchPath
  2800. * \sa PHYSFS_getMountPoint
  2801. */
  2802. PHYSFS_DECL int PHYSFS_mountMemory(const void *buf, PHYSFS_uint64 len,
  2803. void (*del)(void *), const char *fname,
  2804. const char *mountPoint, int appendToPath);
  2805. /**
  2806. * \fn int PHYSFS_mountHandle(PHYSFS_File *file, const char *fname, const char *mountPoint, int appendToPath)
  2807. * \brief Add an archive, contained in a PHYSFS_File handle, to the search path.
  2808. *
  2809. * \warning Unless you have some special, low-level need, you should be using
  2810. * PHYSFS_mount() instead of this.
  2811. *
  2812. * \warning Archives-in-archives may be very slow! While a PHYSFS_File can
  2813. * seek even when the data is compressed, it may do so by rewinding
  2814. * to the start and decompressing everything before the seek point.
  2815. * Normal archive usage may do a lot of seeking behind the scenes.
  2816. * As such, you might find normal archive usage extremely painful
  2817. * if mounted this way. Plan accordingly: if you, say, have a
  2818. * self-extracting .zip file, and want to mount something in it,
  2819. * compress the contents of the inner archive and make sure the outer
  2820. * .zip file doesn't compress the inner archive too.
  2821. *
  2822. * This function operates just like PHYSFS_mount(), but takes a PHYSFS_File
  2823. * handle instead of a pathname. This handle contains all the data of the
  2824. * archive, and is used instead of a real file in the physical filesystem.
  2825. * The PHYSFS_File may be backed by a real file in the physical filesystem,
  2826. * but isn't necessarily. The most popular use for this is likely to mount
  2827. * archives stored inside other archives.
  2828. *
  2829. * (filename) is only used here to optimize archiver selection (if you name it
  2830. * XXXXX.zip, we might try the ZIP archiver first, for example). It doesn't
  2831. * need to refer to a real file at all, and can even be NULL. If the filename
  2832. * isn't helpful, the system will try every archiver until one works or none
  2833. * of them do.
  2834. *
  2835. * (file) must remain until the archive is unmounted. When the archive is
  2836. * unmounted, the system will call PHYSFS_close(file). If you need this
  2837. * handle to survive, you will have to wrap this in a PHYSFS_Io and use
  2838. * PHYSFS_mountIo() instead.
  2839. *
  2840. * If this function fails, PHYSFS_close(file) is not called.
  2841. *
  2842. * \param file The PHYSFS_File handle containing archive data.
  2843. * \param fname Filename that can represent this stream. Can be NULL.
  2844. * \param mountPoint Location in the interpolated tree that this archive
  2845. * will be "mounted", in platform-independent notation.
  2846. * NULL or "" is equivalent to "/".
  2847. * \param appendToPath nonzero to append to search path, zero to prepend.
  2848. * \return nonzero if added to path, zero on failure (bogus archive, etc).
  2849. * Specifics of the error can be gleaned from
  2850. * PHYSFS_getLastError().
  2851. *
  2852. * \sa PHYSFS_unmount
  2853. * \sa PHYSFS_getSearchPath
  2854. * \sa PHYSFS_getMountPoint
  2855. */
  2856. PHYSFS_DECL int PHYSFS_mountHandle(PHYSFS_File *file, const char *fname,
  2857. const char *mountPoint, int appendToPath);
  2858. /**
  2859. * \enum PHYSFS_ErrorCode
  2860. * \brief Values that represent specific causes of failure.
  2861. *
  2862. * Most of the time, you should only concern yourself with whether a given
  2863. * operation failed or not, but there may be occasions where you plan to
  2864. * handle a specific failure case gracefully, so we provide specific error
  2865. * codes.
  2866. *
  2867. * Most of these errors are a little vague, and most aren't things you can
  2868. * fix...if there's a permission error, for example, all you can really do
  2869. * is pass that information on to the user and let them figure out how to
  2870. * handle it. In most these cases, your program should only care that it
  2871. * failed to accomplish its goals, and not care specifically why.
  2872. *
  2873. * \sa PHYSFS_getLastErrorCode
  2874. * \sa PHYSFS_getErrorByCode
  2875. */
  2876. typedef enum PHYSFS_ErrorCode
  2877. {
  2878. PHYSFS_ERR_OK, /**< Success; no error. */
  2879. PHYSFS_ERR_OTHER_ERROR, /**< Error not otherwise covered here. */
  2880. PHYSFS_ERR_OUT_OF_MEMORY, /**< Memory allocation failed. */
  2881. PHYSFS_ERR_NOT_INITIALIZED, /**< PhysicsFS is not initialized. */
  2882. PHYSFS_ERR_IS_INITIALIZED, /**< PhysicsFS is already initialized. */
  2883. PHYSFS_ERR_ARGV0_IS_NULL, /**< Needed argv[0], but it is NULL. */
  2884. PHYSFS_ERR_UNSUPPORTED, /**< Operation or feature unsupported. */
  2885. PHYSFS_ERR_PAST_EOF, /**< Attempted to access past end of file. */
  2886. PHYSFS_ERR_FILES_STILL_OPEN, /**< Files still open. */
  2887. PHYSFS_ERR_INVALID_ARGUMENT, /**< Bad parameter passed to an function. */
  2888. PHYSFS_ERR_NOT_MOUNTED, /**< Requested archive/dir not mounted. */
  2889. PHYSFS_ERR_NOT_FOUND, /**< File (or whatever) not found. */
  2890. PHYSFS_ERR_SYMLINK_FORBIDDEN,/**< Symlink seen when not permitted. */
  2891. PHYSFS_ERR_NO_WRITE_DIR, /**< No write dir has been specified. */
  2892. PHYSFS_ERR_OPEN_FOR_READING, /**< Wrote to a file opened for reading. */
  2893. PHYSFS_ERR_OPEN_FOR_WRITING, /**< Read from a file opened for writing. */
  2894. PHYSFS_ERR_NOT_A_FILE, /**< Needed a file, got a directory (etc). */
  2895. PHYSFS_ERR_READ_ONLY, /**< Wrote to a read-only filesystem. */
  2896. PHYSFS_ERR_CORRUPT, /**< Corrupted data encountered. */
  2897. PHYSFS_ERR_SYMLINK_LOOP, /**< Infinite symbolic link loop. */
  2898. PHYSFS_ERR_IO, /**< i/o error (hardware failure, etc). */
  2899. PHYSFS_ERR_PERMISSION, /**< Permission denied. */
  2900. PHYSFS_ERR_NO_SPACE, /**< No space (disk full, over quota, etc) */
  2901. PHYSFS_ERR_BAD_FILENAME, /**< Filename is bogus/insecure. */
  2902. PHYSFS_ERR_BUSY, /**< Tried to modify a file the OS needs. */
  2903. PHYSFS_ERR_DIR_NOT_EMPTY, /**< Tried to delete dir with files in it. */
  2904. PHYSFS_ERR_OS_ERROR, /**< Unspecified OS-level error. */
  2905. PHYSFS_ERR_DUPLICATE /**< Duplicate entry. */
  2906. } PHYSFS_ErrorCode;
  2907. /**
  2908. * \fn PHYSFS_ErrorCode PHYSFS_getLastErrorCode(void)
  2909. * \brief Get machine-readable error information.
  2910. *
  2911. * Get the last PhysicsFS error message as an integer value. This will return
  2912. * PHYSFS_ERR_OK if there's been no error since the last call to this
  2913. * function. Each thread has a unique error state associated with it, but
  2914. * each time a new error message is set, it will overwrite the previous one
  2915. * associated with that thread. It is safe to call this function at anytime,
  2916. * even before PHYSFS_init().
  2917. *
  2918. * PHYSFS_getLastError() and PHYSFS_getLastErrorCode() both reset the same
  2919. * thread-specific error state. Calling one will wipe out the other's
  2920. * data. If you need both, call PHYSFS_getLastErrorCode(), then pass that
  2921. * value to PHYSFS_getErrorByCode().
  2922. *
  2923. * Generally, applications should only concern themselves with whether a
  2924. * given function failed; however, if you require more specifics, you can
  2925. * try this function to glean information, if there's some specific problem
  2926. * you're expecting and plan to handle. But with most things that involve
  2927. * file systems, the best course of action is usually to give up, report the
  2928. * problem to the user, and let them figure out what should be done about it.
  2929. * For that, you might prefer PHYSFS_getLastError() instead.
  2930. *
  2931. * \return Enumeration value that represents last reported error.
  2932. *
  2933. * \sa PHYSFS_getErrorByCode
  2934. */
  2935. PHYSFS_DECL PHYSFS_ErrorCode PHYSFS_getLastErrorCode(void);
  2936. /**
  2937. * \fn const char *PHYSFS_getErrorByCode(PHYSFS_ErrorCode code)
  2938. * \brief Get human-readable description string for a given error code.
  2939. *
  2940. * Get a static string, in UTF-8 format, that represents an English
  2941. * description of a given error code.
  2942. *
  2943. * This string is guaranteed to never change (although we may add new strings
  2944. * for new error codes in later versions of PhysicsFS), so you can use it
  2945. * for keying a localization dictionary.
  2946. *
  2947. * It is safe to call this function at anytime, even before PHYSFS_init().
  2948. *
  2949. * These strings are meant to be passed on directly to the user.
  2950. * Generally, applications should only concern themselves with whether a
  2951. * given function failed, but not care about the specifics much.
  2952. *
  2953. * Do not attempt to free the returned strings; they are read-only and you
  2954. * don't own their memory pages.
  2955. *
  2956. * \param code Error code to convert to a string.
  2957. * \return READ ONLY string of requested error message, NULL if this
  2958. * is not a valid PhysicsFS error code. Always check for NULL if
  2959. * you might be looking up an error code that didn't exist in an
  2960. * earlier version of PhysicsFS.
  2961. *
  2962. * \sa PHYSFS_getLastErrorCode
  2963. */
  2964. PHYSFS_DECL const char *PHYSFS_getErrorByCode(PHYSFS_ErrorCode code);
  2965. /**
  2966. * \fn void PHYSFS_setErrorCode(PHYSFS_ErrorCode code)
  2967. * \brief Set the current thread's error code.
  2968. *
  2969. * This lets you set the value that will be returned by the next call to
  2970. * PHYSFS_getLastErrorCode(). This will replace any existing error code,
  2971. * whether set by your application or internally by PhysicsFS.
  2972. *
  2973. * Error codes are stored per-thread; what you set here will not be
  2974. * accessible to another thread.
  2975. *
  2976. * Any call into PhysicsFS may change the current error code, so any code you
  2977. * set here is somewhat fragile, and thus you shouldn't build any serious
  2978. * error reporting framework on this function. The primary goal of this
  2979. * function is to allow PHYSFS_Io implementations to set the error state,
  2980. * which generally will be passed back to your application when PhysicsFS
  2981. * makes a PHYSFS_Io call that fails internally.
  2982. *
  2983. * This function doesn't care if the error code is a value known to PhysicsFS
  2984. * or not (but PHYSFS_getErrorByCode() will return NULL for unknown values).
  2985. * The value will be reported unmolested by PHYSFS_getLastErrorCode().
  2986. *
  2987. * \param code Error code to become the current thread's new error state.
  2988. *
  2989. * \sa PHYSFS_getLastErrorCode
  2990. * \sa PHYSFS_getErrorByCode
  2991. */
  2992. PHYSFS_DECL void PHYSFS_setErrorCode(PHYSFS_ErrorCode code);
  2993. /**
  2994. * \fn const char *PHYSFS_getPrefDir(const char *org, const char *app)
  2995. * \brief Get the user-and-app-specific path where files can be written.
  2996. *
  2997. * Helper function.
  2998. *
  2999. * Get the "pref dir". This is meant to be where users can write personal
  3000. * files (preferences and save games, etc) that are specific to your
  3001. * application. This directory is unique per user, per application.
  3002. *
  3003. * This function will decide the appropriate location in the native filesystem,
  3004. * create the directory if necessary, and return a string in
  3005. * platform-dependent notation, suitable for passing to PHYSFS_setWriteDir().
  3006. *
  3007. * On Windows, this might look like:
  3008. * "C:\\Users\\bob\\AppData\\Roaming\\My Company\\My Program Name"
  3009. *
  3010. * On Linux, this might look like:
  3011. * "/home/bob/.local/share/My Program Name"
  3012. *
  3013. * On Mac OS X, this might look like:
  3014. * "/Users/bob/Library/Application Support/My Program Name"
  3015. *
  3016. * (etc.)
  3017. *
  3018. * You should probably use the pref dir for your write dir, and also put it
  3019. * near the beginning of your search path. Older versions of PhysicsFS
  3020. * offered only PHYSFS_getUserDir() and left you to figure out where the
  3021. * files should go under that tree. This finds the correct location
  3022. * for whatever platform, which not only changes between operating systems,
  3023. * but also versions of the same operating system.
  3024. *
  3025. * You specify the name of your organization (if it's not a real organization,
  3026. * your name or an Internet domain you own might do) and the name of your
  3027. * application. These should be proper names.
  3028. *
  3029. * Both the (org) and (app) strings may become part of a directory name, so
  3030. * please follow these rules:
  3031. *
  3032. * - Try to use the same org string (including case-sensitivity) for
  3033. * all your applications that use this function.
  3034. * - Always use a unique app string for each one, and make sure it never
  3035. * changes for an app once you've decided on it.
  3036. * - Unicode characters are legal, as long as it's UTF-8 encoded, but...
  3037. * - ...only use letters, numbers, and spaces. Avoid punctuation like
  3038. * "Game Name 2: Bad Guy's Revenge!" ... "Game Name 2" is sufficient.
  3039. *
  3040. * The pointer returned by this function remains valid until you call this
  3041. * function again, or call PHYSFS_deinit(). This is not necessarily a fast
  3042. * call, though, so you should call this once at startup and copy the string
  3043. * if you need it.
  3044. *
  3045. * You should assume the path returned by this function is the only safe
  3046. * place to write files (and that PHYSFS_getUserDir() and PHYSFS_getBaseDir(),
  3047. * while they might be writable, or even parents of the returned path, aren't
  3048. * where you should be writing things).
  3049. *
  3050. * \param org The name of your organization.
  3051. * \param app The name of your application.
  3052. * \return READ ONLY string of user dir in platform-dependent notation. NULL
  3053. * if there's a problem (creating directory failed, etc).
  3054. *
  3055. * \sa PHYSFS_getBaseDir
  3056. * \sa PHYSFS_getUserDir
  3057. */
  3058. PHYSFS_DECL const char *PHYSFS_getPrefDir(const char *org, const char *app);
  3059. /**
  3060. * \struct PHYSFS_Archiver
  3061. * \brief Abstract interface to provide support for user-defined archives.
  3062. *
  3063. * \warning This is advanced, hardcore stuff. You don't need this unless you
  3064. * really know what you're doing. Most apps will not need this.
  3065. *
  3066. * Historically, PhysicsFS provided a means to mount various archive file
  3067. * formats, and physical directories in the native filesystem. However,
  3068. * applications have been limited to the file formats provided by the
  3069. * library. This interface allows an application to provide their own
  3070. * archive file types.
  3071. *
  3072. * Conceptually, a PHYSFS_Archiver provides directory entries, while
  3073. * PHYSFS_Io provides data streams for those directory entries. The most
  3074. * obvious use of PHYSFS_Archiver is to provide support for an archive
  3075. * file type that isn't provided by PhysicsFS directly: perhaps some
  3076. * proprietary format that only your application needs to understand.
  3077. *
  3078. * Internally, all the built-in archive support uses this interface, so the
  3079. * best examples for building a PHYSFS_Archiver is the source code to
  3080. * PhysicsFS itself.
  3081. *
  3082. * An archiver is added to the system with PHYSFS_registerArchiver(), and then
  3083. * it will be available for use automatically with PHYSFS_mount(); if a
  3084. * given archive can be handled with your archiver, it will be given control
  3085. * as appropriate.
  3086. *
  3087. * These methods deal with dir handles. You have one instance of your
  3088. * archiver, and it generates a unique, opaque handle for each opened
  3089. * archive in its openArchive() method. Since the lifetime of an Archiver
  3090. * (not an archive) is generally the entire lifetime of the process, and it's
  3091. * assumed to be a singleton, we do not provide any instance data for the
  3092. * archiver itself; the app can just use some static variables if necessary.
  3093. *
  3094. * Symlinks should always be followed (except in stat()); PhysicsFS will
  3095. * use the stat() method to check for symlinks and make a judgement on
  3096. * whether to continue to call other methods based on that.
  3097. *
  3098. * Archivers, when necessary, should set the PhysicsFS error state with
  3099. * PHYSFS_setErrorCode() before returning. PhysicsFS will pass these errors
  3100. * back to the application unmolested in most cases.
  3101. *
  3102. * Thread safety: TO BE DECIDED. !!! FIXME
  3103. *
  3104. * \sa PHYSFS_registerArchiver
  3105. * \sa PHYSFS_deregisterArchiver
  3106. * \sa PHYSFS_supportedArchiveTypes
  3107. */
  3108. typedef struct PHYSFS_Archiver
  3109. {
  3110. // !!! FIXME: split read/write interfaces?
  3111. /**
  3112. * \brief Binary compatibility information.
  3113. *
  3114. * This must be set to zero at this time. Future versions of this
  3115. * struct will increment this field, so we know what a given
  3116. * implementation supports. We'll presumably keep supporting older
  3117. * versions as we offer new features, though.
  3118. */
  3119. PHYSFS_uint32 version;
  3120. /**
  3121. * \brief Basic info about this archiver.
  3122. *
  3123. * This is used to identify your archive, and is returned in
  3124. * PHYSFS_supportedArchiveTypes().
  3125. */
  3126. PHYSFS_ArchiveInfo info;
  3127. // !!! FIXME: documentation: \brief?
  3128. /**
  3129. * \brief
  3130. *
  3131. * Open an archive provided by (io).
  3132. * (name) is a filename associated with (io), but doesn't necessarily
  3133. * map to anything, let alone a real filename. This possibly-
  3134. * meaningless name is in platform-dependent notation.
  3135. * (forWrite) is non-zero if this is to be used for
  3136. * the write directory, and zero if this is to be used for an
  3137. * element of the search path.
  3138. * Return NULL on failure. We ignore any error code you set here;
  3139. * when PHYSFS_mount() returns, the error will be PHYSFS_ERR_UNSUPPORTED
  3140. * (no Archivers could handle this data). // !!! FIXME: yeah?
  3141. * Returns non-NULL on success. The pointer returned will be
  3142. * passed as the "opaque" parameter for later calls.
  3143. */
  3144. void *(*openArchive)(PHYSFS_Io *io, const char *name, int forWrite);
  3145. /**
  3146. * List all files in (dirname). Each file is passed to (cb),
  3147. * where a copy is made if appropriate, so you should dispose of
  3148. * it properly upon return from the callback.
  3149. * If you have a failure, report as much as you can.
  3150. * (dirname) is in platform-independent notation.
  3151. */
  3152. void (*enumerateFiles)(void *opaque, const char *dirname,
  3153. PHYSFS_EnumFilesCallback cb,
  3154. const char *origdir, void *callbackdata);
  3155. /**
  3156. * Open file for reading.
  3157. * This filename, (fnm), is in platform-independent notation.
  3158. * If you can't handle multiple opens of the same file,
  3159. * you can opt to fail for the second call.
  3160. * Fail if the file does not exist.
  3161. * Returns NULL on failure, and calls PHYSFS_setErrorCode().
  3162. * Returns non-NULL on success. The pointer returned will be
  3163. * passed as the "opaque" parameter for later file calls.
  3164. */
  3165. PHYSFS_Io *(*openRead)(void *opaque, const char *fnm);
  3166. /**
  3167. * Open file for writing.
  3168. * If the file does not exist, it should be created. If it exists,
  3169. * it should be truncated to zero bytes. The writing
  3170. * offset should be the start of the file.
  3171. * This filename is in platform-independent notation.
  3172. * If you can't handle multiple opens of the same file,
  3173. * you can opt to fail for the second call.
  3174. * Returns NULL on failure, and calls PHYSFS_setErrorCode().
  3175. * Returns non-NULL on success. The pointer returned will be
  3176. * passed as the "opaque" parameter for later file calls.
  3177. */
  3178. PHYSFS_Io *(*openWrite)(void *opaque, const char *filename);
  3179. /**
  3180. * Open file for appending.
  3181. * If the file does not exist, it should be created. The writing
  3182. * offset should be the end of the file.
  3183. * This filename is in platform-independent notation.
  3184. * If you can't handle multiple opens of the same file,
  3185. * you can opt to fail for the second call.
  3186. * Returns NULL on failure, and calls PHYSFS_setErrorCode().
  3187. * Returns non-NULL on success. The pointer returned will be
  3188. * passed as the "opaque" parameter for later file calls.
  3189. */
  3190. PHYSFS_Io *(*openAppend)(void *opaque, const char *filename);
  3191. /**
  3192. * Delete a file in the archive/directory.
  3193. * Return non-zero on success, zero on failure.
  3194. * This filename is in platform-independent notation.
  3195. * This method may be NULL.
  3196. * On failure, call PHYSFS_setErrorCode().
  3197. */
  3198. int (*remove)(void *opaque, const char *filename);
  3199. /**
  3200. * Create a directory in the archive/directory.
  3201. * If the application is trying to make multiple dirs, PhysicsFS
  3202. * will split them up into multiple calls before passing them to
  3203. * your driver.
  3204. * Return non-zero on success, zero on failure.
  3205. * This filename is in platform-independent notation.
  3206. * This method may be NULL.
  3207. * On failure, call PHYSFS_setErrorCode().
  3208. */
  3209. int (*mkdir)(void *opaque, const char *filename);
  3210. /**
  3211. * Obtain basic file metadata.
  3212. * Returns non-zero on success, zero on failure.
  3213. * On failure, call PHYSFS_setErrorCode().
  3214. */
  3215. int (*stat)(void *opaque, const char *fn, PHYSFS_Stat *stat);
  3216. /**
  3217. * Close directories/archives, and free any associated memory,
  3218. * including the original PHYSFS_Io and (opaque) itself, if
  3219. * applicable. Implementation can assume that it won't be called if
  3220. * there are still files open from this archive.
  3221. */
  3222. void (*closeArchive)(void *opaque);
  3223. } PHYSFS_Archiver;
  3224. /**
  3225. * \fn int PHYSFS_registerArchiver(const PHYSFS_Archiver *archiver)
  3226. * \brief Add a new archiver to the system.
  3227. *
  3228. * !!! FIXME: write me.
  3229. *
  3230. * You may not have two archivers that handle the same extension. If you are
  3231. * going to have a clash, you can deregister the other archiver (including
  3232. * built-in ones) with PHYSFS_deregisterArchiver().
  3233. *
  3234. * The data in (archiver) is copied; you may free this pointer when this
  3235. * function returns.
  3236. *
  3237. * \param archiver The archiver to register.
  3238. * \return Zero on error, non-zero on success.
  3239. *
  3240. * \sa PHYSFS_Archiver
  3241. * \sa PHYSFS_deregisterArchiver
  3242. */
  3243. PHYSFS_DECL int PHYSFS_registerArchiver(const PHYSFS_Archiver *archiver);
  3244. /**
  3245. * \fn int PHYSFS_deregisterArchiver(const char *ext)
  3246. * \brief Remove an archiver from the system.
  3247. *
  3248. * !!! FIXME: write me.
  3249. *
  3250. * This fails if there are any archives still open that use this archiver.
  3251. *
  3252. * \param ext Filename extension that the archiver handles.
  3253. * \return Zero on error, non-zero on success.
  3254. *
  3255. * \sa PHYSFS_Archiver
  3256. * \sa PHYSFS_registerArchiver
  3257. */
  3258. PHYSFS_DECL int PHYSFS_deregisterArchiver(const char *ext);
  3259. /* Everything above this line is part of the PhysicsFS 2.1 API. */
  3260. #ifdef __cplusplus
  3261. }
  3262. #endif
  3263. #endif /* !defined _INCLUDE_PHYSFS_H_ */
  3264. /* end of physfs.h ... */