physfssdl3.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*
  2. * This code provides a glue layer between PhysicsFS and Simple Directmedia
  3. * Layer 3's (SDL3) SDL_IOStream and SDL_Storage i/o abstractions.
  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. * SDL3 is zlib-licensed, like PhysicsFS. You can get SDL at
  19. * https://www.libsdl.org/
  20. *
  21. * This file was written by Ryan C. Gordon. (icculus@icculus.org).
  22. */
  23. /* This works with SDL3. For SDL1 and SDL2, use physfsrwops.h */
  24. #ifndef _INCLUDE_PHYSFSSDL3_H_
  25. #define _INCLUDE_PHYSFSSDL3_H_
  26. #include "physfs.h"
  27. #include <SDL3/SDL.h>
  28. #ifdef __cplusplus
  29. extern "C" {
  30. #endif
  31. /* You can either just get SDL_IOStreams directly from a PhysicsFS path,
  32. or make an SDL_Storage that bridges to the PhysicsFS VFS. */
  33. /**
  34. * Open a platform-independent filename for reading, and make it accessible
  35. * via an SDL_IOStream. The file will be closed in PhysicsFS when the
  36. * RWops is closed. PhysicsFS should be configured to your liking before
  37. * opening files through this method.
  38. *
  39. * @param filename File to open in platform-independent notation.
  40. * @return A valid SDL_IOStream on success, NULL on error. Specifics
  41. * of the error can be gleaned from SDL_GetError().
  42. */
  43. PHYSFS_DECL SDL_IOStream *PHYSFSSDL3_openRead(const char *fname);
  44. /**
  45. * Open a platform-independent filename for writing, and make it accessible
  46. * via an SDL_IOStream. The file will be closed in PhysicsFS when the
  47. * RWops is closed. PhysicsFS should be configured to your liking before
  48. * opening files through this method.
  49. *
  50. * @param filename File to open in platform-independent notation.
  51. * @return A valid SDL_IOStream on success, NULL on error. Specifics
  52. * of the error can be gleaned from SDL_GetError().
  53. */
  54. PHYSFS_DECL SDL_IOStream *PHYSFSSDL3_openWrite(const char *fname);
  55. /**
  56. * Open a platform-independent filename for appending, and make it accessible
  57. * via an SDL_IOStream. The file will be closed in PhysicsFS when the
  58. * RWops is closed. PhysicsFS should be configured to your liking before
  59. * opening files through this method.
  60. *
  61. * @param filename File to open in platform-independent notation.
  62. * @return A valid SDL_IOStream on success, NULL on error. Specifics
  63. * of the error can be gleaned from SDL_GetError().
  64. */
  65. PHYSFS_DECL SDL_IOStream *PHYSFSSDL3_openAppend(const char *fname);
  66. /**
  67. * Make a SDL_IOStream from an existing PhysicsFS file handle. You should
  68. * dispose of any references to the handle after successful creation of
  69. * the RWops. The actual PhysicsFS handle will be destroyed when the
  70. * RWops is closed.
  71. *
  72. * @param handle a valid PhysicsFS file handle.
  73. * @return A valid SDL_IOStream on success, NULL on error. Specifics
  74. * of the error can be gleaned from SDL_GetError().
  75. */
  76. PHYSFS_DECL SDL_IOStream *PHYSFSSDL3_makeIOStream(PHYSFS_File *handle);
  77. /**
  78. * Expose the PhysicsFS VFS through an SDL_Storage interface.
  79. * This just makes the global interpolated file tree available
  80. * through SDL3's interface. You can still manipulate it outside
  81. * of SDL_Storage by calling PhysicsFS APIs directly.
  82. *
  83. * @return A valid SDL_Storage on success, NULL on error. Specifics
  84. * of the error can be gleaned from SDL_GetError().
  85. */
  86. PHYSFS_DECL SDL_Storage *PHYSFSSDL3_makeStorage(void);
  87. #ifdef __cplusplus
  88. }
  89. #endif
  90. #endif /* include-once blocker */
  91. /* end of physfssdl3.h ... */