physfs.h 141 KB

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