SDL_sysfilesystem.cpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
  4. This software is provided 'as-is', without any express or implied
  5. warranty. In no event will the authors be held liable for any damages
  6. arising from the use of this software.
  7. Permission is granted to anyone to use this software for any purpose,
  8. including commercial applications, and to alter it and redistribute it
  9. freely, subject to the following restrictions:
  10. 1. The origin of this software must not be misrepresented; you must not
  11. claim that you wrote the original software. If you use this software
  12. in a product, an acknowledgment in the product documentation would be
  13. appreciated but is not required.
  14. 2. Altered source versions must be plainly marked as such, and must not be
  15. misrepresented as being the original software.
  16. 3. This notice may not be removed or altered from any source distribution.
  17. */
  18. #ifdef __cplusplus
  19. extern "C" {
  20. #endif
  21. #include "SDL_internal.h"
  22. #ifdef __cplusplus
  23. }
  24. #endif
  25. #include <e32base.h>
  26. #include <e32std.h>
  27. #include <f32file.h>
  28. #include <utf.h>
  29. #ifdef __cplusplus
  30. extern "C" {
  31. #endif
  32. void NGAGE_GetAppPath(char *path)
  33. {
  34. TBuf<512> aPath;
  35. TFileName fullExePath = RProcess().FileName();
  36. TParsePtrC parser(fullExePath);
  37. aPath.Copy(parser.DriveAndPath());
  38. TBuf8<512> utf8Path; // Temporary buffer for UTF-8 data.
  39. CnvUtfConverter::ConvertFromUnicodeToUtf8(utf8Path, aPath);
  40. // Copy UTF-8 data to the provided char* buffer.
  41. strncpy(path, (const char *)utf8Path.Ptr(), utf8Path.Length());
  42. path[utf8Path.Length()] = '\0';
  43. // Replace backslashes with forward slashes.
  44. for (int i = 0; i < utf8Path.Length(); i++)
  45. {
  46. if (path[i] == '\\')
  47. {
  48. path[i] = '/';
  49. }
  50. }
  51. }
  52. #ifdef __cplusplus
  53. }
  54. #endif