util.m 966 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #include <Foundation/Foundation.h>
  2. #include "common.h"
  3. #include "SDL_filesystem.h"
  4. LPCSTR
  5. UTIL_IOS_BasePath(
  6. VOID
  7. )
  8. {
  9. static char buf[4096] = "";
  10. if (buf[0] == '\0')
  11. {
  12. #ifdef CYDIA
  13. char *p = SDL_GetBasePath();
  14. if (p != NULL)
  15. {
  16. strcpy(buf, p);
  17. free(p);
  18. }
  19. #else
  20. NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
  21. NSString *documentsDirectory = [[paths objectAtIndex:0] stringByAppendingString:@"/"];
  22. strcpy(buf, [documentsDirectory UTF8String]);
  23. #endif
  24. }
  25. return buf;
  26. }
  27. LPCSTR
  28. UTIL_IOS_SavePath(
  29. VOID
  30. )
  31. {
  32. static char buf[4096] = "";
  33. if (buf[0] == '\0')
  34. {
  35. NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
  36. NSString *documentsDirectory = [[paths objectAtIndex:0] stringByAppendingString:@"/"];
  37. strcpy(buf, [documentsDirectory UTF8String]);
  38. }
  39. return buf;
  40. }