sdlfilesystem.inc 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. {*
  2. * \file SDL_filesystem.h
  3. *
  4. * \brief Include file for filesystem SDL API functions
  5. }
  6. {*
  7. * Get the directory where the application was run from.
  8. *
  9. * This is not necessarily a fast call, so you should call this once near
  10. * startup and save the string if you need it.
  11. *
  12. * **Mac OS X and iOS Specific Functionality**: If the application is in a
  13. * ".app" bundle, this function returns the Resource directory (e.g.
  14. * MyApp.app/Contents/Resources/). This behaviour can be overridden by adding
  15. * a property to the Info.plist file. Adding a string key with the name
  16. * SDL_FILESYSTEM_BASE_DIR_TYPE with a supported value will change the
  17. * behaviour.
  18. *
  19. * Supported values for the SDL_FILESYSTEM_BASE_DIR_TYPE property (Given an
  20. * application in /Applications/SDLApp/MyApp.app):
  21. *
  22. * - `resource`: bundle resource directory (the default). For example:
  23. * `/Applications/SDLApp/MyApp.app/Contents/Resources`
  24. * - `bundle`: the Bundle directory. For example:
  25. * `/Applications/SDLApp/MyApp.app/`
  26. * - `parent`: the containing directory of the bundle. For example:
  27. * `/Applications/SDLApp/`
  28. *
  29. * The returned path is guaranteed to end with a path separator ('\' on
  30. * Windows, '/' on most other platforms).
  31. *
  32. * The pointer returned is owned by the caller. Please call SDL_free() on the
  33. * pointer when done with it.
  34. *
  35. * \returns an absolute path in UTF-8 encoding to the application data
  36. * directory. nil will be returned on error or when the platform
  37. * doesn't implement this functionality, call SDL_GetError() for more
  38. * information.
  39. *
  40. * \since This function is available since SDL 2.0.1.
  41. *
  42. * \sa SDL_GetPrefPath
  43. }
  44. function SDL_GetBasePath(): PAnsiChar; cdecl;
  45. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GetBasePath' {$ENDIF} {$ENDIF};
  46. {*
  47. * Get the user-and-app-specific path where files can be written.
  48. *
  49. * Get the "pref dir". This is meant to be where users can write personal
  50. * files (preferences and save games, etc) that are specific to your
  51. * application. This directory is unique per user, per application.
  52. *
  53. * This function will decide the appropriate location in the native
  54. * filesystem, create the directory if necessary, and return a string of the
  55. * absolute path to the directory in UTF-8 encoding.
  56. *
  57. * On Windows, the string might look like:
  58. *
  59. * `C:\\Users\\bob\\AppData\\Roaming\\My Company\\My Program Name\\`
  60. *
  61. * On Linux, the string might look like:
  62. *
  63. * `/home/bob/.local/share/My Program Name/`
  64. *
  65. * On Mac OS X, the string might look like:
  66. *
  67. * `/Users/bob/Library/Application Support/My Program Name/`
  68. *
  69. * You should assume the path returned by this function is the only safe place
  70. * to write files (and that SDL_GetBasePath(), while it might be writable, or
  71. * even the parent of the returned path, isn't where you should be writing
  72. * things).
  73. *
  74. * Both the org and app strings may become part of a directory name, so please
  75. * follow these rules:
  76. *
  77. * - Try to use the same org string (_including case-sensitivity_) for all
  78. * your applications that use this function.
  79. * - Always use a unique app string for each one, and make sure it never
  80. * changes for an app once you've decided on it.
  81. * - Unicode characters are legal, as long as it's UTF-8 encoded, but...
  82. * - ...only use letters, numbers, and spaces. Avoid punctuation like "Game
  83. * Name 2: Bad Guy's Revenge!" ... "Game Name 2" is sufficient.
  84. *
  85. * The returned path is guaranteed to end with a path separator ('\' on
  86. * Windows, '/' on most other platforms).
  87. *
  88. * The pointer returned is owned by the caller. Please call SDL_free() on the
  89. * pointer when done with it.
  90. *
  91. * \param org the name of your organization
  92. * \param app the name of your application
  93. * \returns a UTF-8 string of the user directory in platform-dependent
  94. * notation. nil if there's a problem (creating directory failed,
  95. * etc.).
  96. *
  97. * \since This function is available since SDL 2.0.1.
  98. *
  99. * \sa SDL_GetBasePath
  100. }
  101. function SDL_GetPrefPath(org: PAnsiChar; app: PAnsiChar): PAnsiChar; cdecl;
  102. external {$IFDEF DYNAMIC_LINK}SDL_LibName{$ENDIF} {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GetPrefPath' {$ENDIF} {$ENDIF};