1
0

physfsrwops.h 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * This code provides a glue layer between PhysicsFS and Simple Directmedia
  3. * Layer's (SDL) RWops i/o abstraction.
  4. *
  5. * License: this code is public domain. I make no warranty that it is useful,
  6. * correct, harmless, or environmentally safe.
  7. *
  8. * This particular file may be used however you like, including copying it
  9. * verbatim into a closed-source project, exploiting it commercially, and
  10. * removing any trace of my name from the source (although I hope you won't
  11. * do that). I welcome enhancements and corrections to this file, but I do
  12. * not require you to send me patches if you make changes. This code has
  13. * NO WARRANTY.
  14. *
  15. * Unless otherwise stated, the rest of PhysicsFS falls under the zlib license.
  16. * Please see LICENSE.txt in the root of the source tree.
  17. *
  18. * SDL 1.2 falls under the LGPL license. SDL 1.3+ is zlib, like PhysicsFS.
  19. * You can get SDL at https://www.libsdl.org/
  20. *
  21. * This file was written by Ryan C. Gordon. (icculus@icculus.org).
  22. */
  23. /* This works with SDL1 and SDL2. For SDL3, use physfssdl3.h */
  24. #ifndef _INCLUDE_PHYSFSRWOPS_H_
  25. #define _INCLUDE_PHYSFSRWOPS_H_
  26. #include "physfs.h"
  27. #include "SDL.h"
  28. #ifdef __cplusplus
  29. extern "C" {
  30. #endif
  31. /**
  32. * Open a platform-independent filename for reading, and make it accessible
  33. * via an SDL_RWops structure. The file will be closed in PhysicsFS when the
  34. * RWops is closed. PhysicsFS should be configured to your liking before
  35. * opening files through this method.
  36. *
  37. * @param filename File to open in platform-independent notation.
  38. * @return A valid SDL_RWops structure on success, NULL on error. Specifics
  39. * of the error can be gleaned from PHYSFS_getLastError().
  40. */
  41. PHYSFS_DECL SDL_RWops *PHYSFSRWOPS_openRead(const char *fname);
  42. /**
  43. * Open a platform-independent filename for writing, and make it accessible
  44. * via an SDL_RWops structure. The file will be closed in PhysicsFS when the
  45. * RWops is closed. PhysicsFS should be configured to your liking before
  46. * opening files through this method.
  47. *
  48. * @param filename File to open in platform-independent notation.
  49. * @return A valid SDL_RWops structure on success, NULL on error. Specifics
  50. * of the error can be gleaned from PHYSFS_getLastError().
  51. */
  52. PHYSFS_DECL SDL_RWops *PHYSFSRWOPS_openWrite(const char *fname);
  53. /**
  54. * Open a platform-independent filename for appending, and make it accessible
  55. * via an SDL_RWops structure. The file will be closed in PhysicsFS when the
  56. * RWops is closed. PhysicsFS should be configured to your liking before
  57. * opening files through this method.
  58. *
  59. * @param filename File to open in platform-independent notation.
  60. * @return A valid SDL_RWops structure on success, NULL on error. Specifics
  61. * of the error can be gleaned from PHYSFS_getLastError().
  62. */
  63. PHYSFS_DECL SDL_RWops *PHYSFSRWOPS_openAppend(const char *fname);
  64. /**
  65. * Make a SDL_RWops from an existing PhysicsFS file handle. You should
  66. * dispose of any references to the handle after successful creation of
  67. * the RWops. The actual PhysicsFS handle will be destroyed when the
  68. * RWops is closed.
  69. *
  70. * @param handle a valid PhysicsFS file handle.
  71. * @return A valid SDL_RWops structure on success, NULL on error. Specifics
  72. * of the error can be gleaned from PHYSFS_getLastError().
  73. */
  74. PHYSFS_DECL SDL_RWops *PHYSFSRWOPS_makeRWops(PHYSFS_File *handle);
  75. #ifdef __cplusplus
  76. }
  77. #endif
  78. #endif /* include-once blocker */
  79. /* end of physfsrwops.h ... */