vfs.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /* Copyright (C) 2010-2019 The RetroArch team
  2. *
  3. * ---------------------------------------------------------------------------------------
  4. * The following license statement only applies to this file (vfs_implementation.h).
  5. * ---------------------------------------------------------------------------------------
  6. *
  7. * Permission is hereby granted, free of charge,
  8. * to any person obtaining a copy of this software and associated documentation files (the "Software"),
  9. * to deal in the Software without restriction, including without limitation the rights to
  10. * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
  11. * and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
  12. *
  13. * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
  14. *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
  16. * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  18. * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  19. * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  21. */
  22. #ifndef __LIBRETRO_SDK_VFS_H
  23. #define __LIBRETRO_SDK_VFS_H
  24. #include <retro_common_api.h>
  25. #include <boolean.h>
  26. #ifdef RARCH_INTERNAL
  27. #ifndef VFS_FRONTEND
  28. #define VFS_FRONTEND
  29. #endif
  30. #endif
  31. RETRO_BEGIN_DECLS
  32. #ifdef _WIN32
  33. typedef void* HANDLE;
  34. #endif
  35. #ifdef HAVE_CDROM
  36. typedef struct
  37. {
  38. char *cue_buf;
  39. size_t cue_len;
  40. int64_t byte_pos;
  41. char drive;
  42. unsigned char cur_min;
  43. unsigned char cur_sec;
  44. unsigned char cur_frame;
  45. unsigned char cur_track;
  46. unsigned cur_lba;
  47. unsigned last_frame_lba;
  48. unsigned char last_frame[2352];
  49. bool last_frame_valid;
  50. } vfs_cdrom_t;
  51. #endif
  52. enum vfs_scheme
  53. {
  54. VFS_SCHEME_NONE = 0,
  55. VFS_SCHEME_CDROM
  56. };
  57. #ifndef __WINRT__
  58. #ifdef VFS_FRONTEND
  59. struct retro_vfs_file_handle
  60. #else
  61. struct libretro_vfs_implementation_file
  62. #endif
  63. {
  64. int fd;
  65. unsigned hints;
  66. int64_t size;
  67. char *buf;
  68. FILE *fp;
  69. #ifdef _WIN32
  70. HANDLE fh;
  71. #endif
  72. char* orig_path;
  73. uint64_t mappos;
  74. uint64_t mapsize;
  75. uint8_t *mapped;
  76. enum vfs_scheme scheme;
  77. #ifdef HAVE_CDROM
  78. vfs_cdrom_t cdrom;
  79. #endif
  80. };
  81. #endif
  82. /* Replace the following symbol with something appropriate
  83. * to signify the file is being compiled for a front end instead of a core.
  84. * This allows the same code to act as reference implementation
  85. * for VFS and as fallbacks for when the front end does not provide VFS functionality.
  86. */
  87. #ifdef VFS_FRONTEND
  88. typedef struct retro_vfs_file_handle libretro_vfs_implementation_file;
  89. #else
  90. typedef struct libretro_vfs_implementation_file libretro_vfs_implementation_file;
  91. #endif
  92. #ifdef VFS_FRONTEND
  93. typedef struct retro_vfs_dir_handle libretro_vfs_implementation_dir;
  94. #else
  95. typedef struct libretro_vfs_implementation_dir libretro_vfs_implementation_dir;
  96. #endif
  97. RETRO_END_DECLS
  98. #endif