util.mm 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #include <Foundation/Foundation.h>
  2. #include <UIKit/UIKit.h>
  3. #include "common.h"
  4. #include "palcfg.h"
  5. #include "util.h"
  6. LPCSTR
  7. UTIL_BasePath(
  8. VOID
  9. )
  10. {
  11. static char buf[4096] = "";
  12. if (buf[0] == '\0')
  13. {
  14. #ifdef CYDIA
  15. char *p = SDL_GetBasePath();
  16. if (p != NULL)
  17. {
  18. strcpy(buf, p);
  19. free(p);
  20. }
  21. #else
  22. NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
  23. NSString *documentsDirectory = [[paths objectAtIndex:0] stringByAppendingString:@"/"];
  24. strcpy(buf, [documentsDirectory UTF8String]);
  25. #endif
  26. }
  27. return buf;
  28. }
  29. LPCSTR
  30. UTIL_SavePath(
  31. VOID
  32. )
  33. {
  34. static char buf[4096] = "";
  35. if (buf[0] == '\0')
  36. {
  37. NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
  38. NSString *documentsDirectory = [[paths objectAtIndex:0] stringByAppendingString:@"/"];
  39. strcpy(buf, [documentsDirectory UTF8String]);
  40. }
  41. return buf;
  42. }
  43. BOOL
  44. UTIL_GetScreenSize(
  45. DWORD *pdwScreenWidth,
  46. DWORD *pdwScreenHeight
  47. )
  48. {
  49. return (pdwScreenWidth && pdwScreenHeight && *pdwScreenWidth && *pdwScreenHeight);
  50. }
  51. BOOL
  52. UTIL_IsAbsolutePath(
  53. LPCSTR lpszFileName
  54. )
  55. {
  56. return FALSE;
  57. }
  58. INT
  59. UTIL_Platform_Init(
  60. int argc,
  61. char* argv[]
  62. )
  63. {
  64. UTIL_LogAddOutputCallback([](LOGLEVEL, const char* str, const char*)->void {
  65. NSLog(@"%s",str);
  66. }, PAL_DEFAULT_LOGLEVEL);
  67. gConfig.fLaunchSetting = NO;
  68. return 0;
  69. }
  70. VOID
  71. UTIL_Platform_Quit(
  72. VOID
  73. )
  74. {
  75. }