WinPhoneUtil.cpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #include <wrl.h>
  2. #include <stdio.h>
  3. static const char *
  4. GetRootPath()
  5. {
  6. static char buf[1024] = "";
  7. if (buf[0] == '\0')
  8. {
  9. Platform::String^ localfolder = Windows::Storage::ApplicationData::Current->LocalFolder->Path;
  10. const char16 *begin = localfolder->Begin();
  11. WideCharToMultiByte(CP_ACP, 0, begin, -1, buf, 1024, NULL, FALSE);
  12. }
  13. return buf;
  14. }
  15. static const char *
  16. GetInstallPath()
  17. {
  18. static char buf[1024] = "";
  19. if (buf[0] == '\0')
  20. {
  21. Platform::String^ installfolder = Windows::ApplicationModel::Package::Current->InstalledLocation->Path;
  22. const char16 *begin = installfolder->Begin();
  23. WideCharToMultiByte(CP_ACP, 0, begin, -1, buf, 1024, NULL, FALSE);
  24. }
  25. return buf;
  26. }
  27. extern "C" FILE *
  28. MY_fopen(const char *path, const char *mode)
  29. {
  30. const char *p = GetRootPath();
  31. char buf[1024];
  32. _snprintf_s(buf, 1024, "%s\\%s", p, path);
  33. FILE *fp = _fsopen(buf, mode, 0x40);
  34. if (fp == NULL)
  35. {
  36. p = GetInstallPath();
  37. _snprintf_s(buf, 1024, "%s\\%s", p, path);
  38. fp = _fsopen(buf, mode, 0x40);
  39. }
  40. return fp;
  41. }
  42. extern "C" void
  43. WinPhone_OnBackKeyPress()
  44. {
  45. }