SDL_filesystem.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2014 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. /**
  19. * \file SDL_filesystem.h
  20. *
  21. * \brief Include file for filesystem SDL API functions
  22. */
  23. #ifndef _SDL_filesystem_h
  24. #define _SDL_filesystem_h
  25. #include "SDL_stdinc.h"
  26. #include "begin_code.h"
  27. /* Set up for C function definitions, even when using C++ */
  28. #ifdef __cplusplus
  29. extern "C" {
  30. #endif
  31. /**
  32. * \brief Get the path where the application resides.
  33. *
  34. * Get the "base path". This is the directory where the application was run
  35. * from, which is probably the installation directory, and may or may not
  36. * be the process's current working directory.
  37. *
  38. * This returns an absolute path in UTF-8 encoding, and is guaranteed to
  39. * end with a path separator ('\\' on Windows, '/' most other places).
  40. *
  41. * The pointer returned by this function is owned by you. Please call
  42. * SDL_free() on the pointer when you are done with it, or it will be a
  43. * memory leak. This is not necessarily a fast call, though, so you should
  44. * call this once near startup and save the string if you need it.
  45. *
  46. * Some platforms can't determine the application's path, and on other
  47. * platforms, this might be meaningless. In such cases, this function will
  48. * return NULL.
  49. *
  50. * \return String of base dir in UTF-8 encoding, or NULL on error.
  51. *
  52. * \sa SDL_GetPrefPath
  53. */
  54. extern DECLSPEC char *SDLCALL SDL_GetBasePath(void);
  55. /**
  56. * \brief Get the user-and-app-specific path where files can be written.
  57. *
  58. * Get the "pref dir". This is meant to be where users can write personal
  59. * files (preferences and save games, etc) that are specific to your
  60. * application. This directory is unique per user, per application.
  61. *
  62. * This function will decide the appropriate location in the native filesystem,
  63. * create the directory if necessary, and return a string of the absolute
  64. * path to the directory in UTF-8 encoding.
  65. *
  66. * On Windows, the string might look like:
  67. * "C:\\Users\\bob\\AppData\\Roaming\\My Company\\My Program Name\\"
  68. *
  69. * On Linux, the string might look like:
  70. * "/home/bob/.local/share/My Program Name/"
  71. *
  72. * On Mac OS X, the string might look like:
  73. * "/Users/bob/Library/Application Support/My Program Name/"
  74. *
  75. * (etc.)
  76. *
  77. * You specify the name of your organization (if it's not a real organization,
  78. * your name or an Internet domain you own might do) and the name of your
  79. * application. These should be untranslated proper names.
  80. *
  81. * Both the org and app strings may become part of a directory name, so
  82. * please follow these rules:
  83. *
  84. * - Try to use the same org string (including case-sensitivity) for
  85. * all your applications that use this function.
  86. * - Always use a unique app string for each one, and make sure it never
  87. * changes for an app once you've decided on it.
  88. * - Unicode characters are legal, as long as it's UTF-8 encoded, but...
  89. * - ...only use letters, numbers, and spaces. Avoid punctuation like
  90. * "Game Name 2: Bad Guy's Revenge!" ... "Game Name 2" is sufficient.
  91. *
  92. * This returns an absolute path in UTF-8 encoding, and is guaranteed to
  93. * end with a path separator ('\\' on Windows, '/' most other places).
  94. *
  95. * The pointer returned by this function is owned by you. Please call
  96. * SDL_free() on the pointer when you are done with it, or it will be a
  97. * memory leak. This is not necessarily a fast call, though, so you should
  98. * call this once near startup and save the string if you need it.
  99. *
  100. * You should assume the path returned by this function is the only safe
  101. * place to write files (and that SDL_GetBasePath(), while it might be
  102. * writable, or even the parent of the returned path, aren't where you
  103. * should be writing things).
  104. *
  105. * Some platforms can't determine the pref path, and on other
  106. * platforms, this might be meaningless. In such cases, this function will
  107. * return NULL.
  108. *
  109. * \param org The name of your organization.
  110. * \param app The name of your application.
  111. * \return UTF-8 string of user dir in platform-dependent notation. NULL
  112. * if there's a problem (creating directory failed, etc).
  113. *
  114. * \sa SDL_GetBasePath
  115. */
  116. extern DECLSPEC char *SDLCALL SDL_GetPrefPath(const char *org, const char *app);
  117. /* Ends C function definitions when using C++ */
  118. #ifdef __cplusplus
  119. }
  120. #endif
  121. #include "close_code.h"
  122. #endif /* _SDL_system_h */
  123. /* vi: set ts=4 sw=4 expandtab: */