skeleton.c 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. /*
  2. * Skeleton platform-dependent support routines for PhysicsFS.
  3. *
  4. * Please see the file LICENSE.txt in the source's root directory.
  5. *
  6. * This file written by Ryan C. Gordon.
  7. */
  8. #error DO NOT COMPILE THIS. IT IS JUST A SKELETON EXAMPLE FILE.
  9. #define __PHYSICSFS_INTERNAL__
  10. #include "physfs_platforms.h"
  11. #ifdef PHYSFS_PLATFORM_SKELETON
  12. #include "physfs_internal.h"
  13. const char *__PHYSFS_platformDirSeparator = ":";
  14. int __PHYSFS_platformInit(void)
  15. {
  16. return(1); /* always succeed. */
  17. } /* __PHYSFS_platformInit */
  18. int __PHYSFS_platformDeinit(void)
  19. {
  20. return(1); /* always succeed. */
  21. } /* __PHYSFS_platformDeinit */
  22. void __PHYSFS_platformDetectAvailableCDs(PHYSFS_StringCallback cb, void *data)
  23. {
  24. } /* __PHYSFS_platformDetectAvailableCDs */
  25. char *__PHYSFS_platformCalcBaseDir(const char *argv0)
  26. {
  27. BAIL_MACRO(ERR_NOT_IMPLEMENTED, NULL);
  28. } /* __PHYSFS_platformCalcBaseDir */
  29. char *__PHYSFS_platformGetUserName(void)
  30. {
  31. BAIL_MACRO(ERR_NOT_IMPLEMENTED, NULL);
  32. } /* __PHYSFS_platformGetUserName */
  33. char *__PHYSFS_platformGetUserDir(void)
  34. {
  35. BAIL_MACRO(ERR_NOT_IMPLEMENTED, NULL);
  36. } /* __PHYSFS_platformGetUserDir */
  37. PHYSFS_uint64 __PHYSFS_platformGetThreadID(void)
  38. {
  39. return(1); /* single threaded. */
  40. } /* __PHYSFS_platformGetThreadID */
  41. int __PHYSFS_platformExists(const char *fname)
  42. {
  43. BAIL_MACRO(ERR_NOT_IMPLEMENTED, 0);
  44. } /* __PHYSFS_platformExists */
  45. int __PHYSFS_platformIsSymLink(const char *fname)
  46. {
  47. BAIL_MACRO(ERR_NOT_IMPLEMENTED, 0);
  48. } /* __PHYSFS_platformIsSymlink */
  49. int __PHYSFS_platformIsDirectory(const char *fname)
  50. {
  51. BAIL_MACRO(ERR_NOT_IMPLEMENTED, 0);
  52. } /* __PHYSFS_platformIsDirectory */
  53. char *__PHYSFS_platformCvtToDependent(const char *prepend,
  54. const char *dirName,
  55. const char *append)
  56. {
  57. BAIL_MACRO(ERR_NOT_IMPLEMENTED, NULL);
  58. } /* __PHYSFS_platformCvtToDependent */
  59. void __PHYSFS_platformTimeslice(void)
  60. {
  61. } /* __PHYSFS_platformTimeslice */
  62. void __PHYSFS_platformEnumerateFiles(const char *dirname,
  63. int omitSymLinks,
  64. PHYSFS_EnumFilesCallback callback,
  65. const char *origdir,
  66. void *callbackdata)
  67. {
  68. } /* __PHYSFS_platformEnumerateFiles */
  69. char *__PHYSFS_platformCurrentDir(void)
  70. {
  71. BAIL_MACRO(ERR_NOT_IMPLEMENTED, NULL);
  72. } /* __PHYSFS_platformCurrentDir */
  73. char *__PHYSFS_platformRealPath(const char *path)
  74. {
  75. BAIL_MACRO(ERR_NOT_IMPLEMENTED, NULL);
  76. } /* __PHYSFS_platformRealPath */
  77. int __PHYSFS_platformMkDir(const char *path)
  78. {
  79. BAIL_MACRO(ERR_NOT_IMPLEMENTED, 0);
  80. } /* __PHYSFS_platformMkDir */
  81. void *__PHYSFS_platformOpenRead(const char *filename)
  82. {
  83. BAIL_MACRO(ERR_NOT_IMPLEMENTED, NULL);
  84. } /* __PHYSFS_platformOpenRead */
  85. void *__PHYSFS_platformOpenWrite(const char *filename)
  86. {
  87. BAIL_MACRO(ERR_NOT_IMPLEMENTED, NULL);
  88. } /* __PHYSFS_platformOpenWrite */
  89. void *__PHYSFS_platformOpenAppend(const char *filename)
  90. {
  91. BAIL_MACRO(ERR_NOT_IMPLEMENTED, NULL);
  92. } /* __PHYSFS_platformOpenAppend */
  93. PHYSFS_sint64 __PHYSFS_platformRead(void *opaque, void *buffer,
  94. PHYSFS_uint32 size, PHYSFS_uint32 count)
  95. {
  96. BAIL_MACRO(ERR_NOT_IMPLEMENTED, -1);
  97. } /* __PHYSFS_platformRead */
  98. PHYSFS_sint64 __PHYSFS_platformWrite(void *opaque, const void *buffer,
  99. PHYSFS_uint32 size, PHYSFS_uint32 count)
  100. {
  101. BAIL_MACRO(ERR_NOT_IMPLEMENTED, -1);
  102. } /* __PHYSFS_platformWrite */
  103. int __PHYSFS_platformSeek(void *opaque, PHYSFS_uint64 pos)
  104. {
  105. BAIL_MACRO(ERR_NOT_IMPLEMENTED, -1);
  106. } /* __PHYSFS_platformSeek */
  107. PHYSFS_sint64 __PHYSFS_platformTell(void *opaque)
  108. {
  109. BAIL_MACRO(ERR_NOT_IMPLEMENTED, -1);
  110. } /* __PHYSFS_platformTell */
  111. PHYSFS_sint64 __PHYSFS_platformFileLength(void *opaque)
  112. {
  113. BAIL_MACRO(ERR_NOT_IMPLEMENTED, -1);
  114. } /* __PHYSFS_platformFileLength */
  115. int __PHYSFS_platformEOF(void *opaque)
  116. {
  117. BAIL_MACRO(ERR_NOT_IMPLEMENTED, -1);
  118. } /* __PHYSFS_platformEOF */
  119. int __PHYSFS_platformFlush(void *opaque)
  120. {
  121. BAIL_MACRO(ERR_NOT_IMPLEMENTED, 0);
  122. } /* __PHYSFS_platformFlush */
  123. int __PHYSFS_platformClose(void *opaque)
  124. {
  125. BAIL_MACRO(ERR_NOT_IMPLEMENTED, 0);
  126. } /* __PHYSFS_platformClose */
  127. int __PHYSFS_platformDelete(const char *path)
  128. {
  129. BAIL_MACRO(ERR_NOT_IMPLEMENTED, 0);
  130. } /* __PHYSFS_platformDelete */
  131. void *__PHYSFS_platformCreateMutex(void)
  132. {
  133. BAIL_MACRO(ERR_NOT_IMPLEMENTED, NULL);
  134. } /* __PHYSFS_platformCreateMutex */
  135. void __PHYSFS_platformDestroyMutex(void *mutex)
  136. {
  137. } /* __PHYSFS_platformDestroyMutex */
  138. int __PHYSFS_platformGrabMutex(void *mutex)
  139. {
  140. /* not implemented, but can't call __PHYSFS_setError! */
  141. return(0);
  142. } /* __PHYSFS_platformGrabMutex */
  143. void __PHYSFS_platformReleaseMutex(void *mutex)
  144. {
  145. /* not implemented, but can't call __PHYSFS_setError! */
  146. } /* __PHYSFS_platformReleaseMutex */
  147. PHYSFS_sint64 __PHYSFS_platformGetLastModTime(const char *fname)
  148. {
  149. BAIL_MACRO(ERR_NOT_IMPLEMENTED, -1);
  150. } /* __PHYSFS_platformGetLastModTime */
  151. int __PHYSFS_platformAllocatorInit(void)
  152. {
  153. return(1); /* always succeeds. */
  154. } /* __PHYSFS_platformAllocatorInit */
  155. void __PHYSFS_platformAllocatorDeinit(void)
  156. {
  157. /* no-op */
  158. } /* __PHYSFS_platformAllocatorInit */
  159. void *__PHYSFS_platformAllocatorMalloc(PHYSFS_uint64 s)
  160. {
  161. BAIL_IF_MACRO(__PHYSFS_ui64FitsAddressSpace(s), ERR_OUT_OF_MEMORY, NULL);
  162. #undef malloc
  163. return(malloc((size_t) s));
  164. } /* __PHYSFS_platformMalloc */
  165. void *__PHYSFS_platformAllocatorRealloc(void *ptr, PHYSFS_uint64 s)
  166. {
  167. BAIL_IF_MACRO(__PHYSFS_ui64FitsAddressSpace(s), ERR_OUT_OF_MEMORY, NULL);
  168. #undef realloc
  169. return(realloc(ptr, (size_t) s));
  170. } /* __PHYSFS_platformRealloc */
  171. void __PHYSFS_platformAllocatorFree(void *ptr)
  172. {
  173. #undef free
  174. free(ptr);
  175. } /* __PHYSFS_platformAllocatorFree */
  176. #endif /* PHYSFS_PLATFORM_SKELETON */
  177. /* end of skeleton.c ... */