SDL standard library
SDL_filesystem.h@0:dda4f4550403, 2016-09-07 (annotated)
- Committer:
- miruga27
- Date:
- Wed Sep 07 18:46:53 2016 +0000
- Revision:
- 0:dda4f4550403
7/09/2016;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
miruga27 | 0:dda4f4550403 | 1 | /* |
miruga27 | 0:dda4f4550403 | 2 | Simple DirectMedia Layer |
miruga27 | 0:dda4f4550403 | 3 | Copyright (C) 1997-2014 Sam Lantinga <slouken@libsdl.org> |
miruga27 | 0:dda4f4550403 | 4 | |
miruga27 | 0:dda4f4550403 | 5 | This software is provided 'as-is', without any express or implied |
miruga27 | 0:dda4f4550403 | 6 | warranty. In no event will the authors be held liable for any damages |
miruga27 | 0:dda4f4550403 | 7 | arising from the use of this software. |
miruga27 | 0:dda4f4550403 | 8 | |
miruga27 | 0:dda4f4550403 | 9 | Permission is granted to anyone to use this software for any purpose, |
miruga27 | 0:dda4f4550403 | 10 | including commercial applications, and to alter it and redistribute it |
miruga27 | 0:dda4f4550403 | 11 | freely, subject to the following restrictions: |
miruga27 | 0:dda4f4550403 | 12 | |
miruga27 | 0:dda4f4550403 | 13 | 1. The origin of this software must not be misrepresented; you must not |
miruga27 | 0:dda4f4550403 | 14 | claim that you wrote the original software. If you use this software |
miruga27 | 0:dda4f4550403 | 15 | in a product, an acknowledgment in the product documentation would be |
miruga27 | 0:dda4f4550403 | 16 | appreciated but is not required. |
miruga27 | 0:dda4f4550403 | 17 | 2. Altered source versions must be plainly marked as such, and must not be |
miruga27 | 0:dda4f4550403 | 18 | misrepresented as being the original software. |
miruga27 | 0:dda4f4550403 | 19 | 3. This notice may not be removed or altered from any source distribution. |
miruga27 | 0:dda4f4550403 | 20 | */ |
miruga27 | 0:dda4f4550403 | 21 | |
miruga27 | 0:dda4f4550403 | 22 | /** |
miruga27 | 0:dda4f4550403 | 23 | * \file SDL_filesystem.h |
miruga27 | 0:dda4f4550403 | 24 | * |
miruga27 | 0:dda4f4550403 | 25 | * \brief Include file for filesystem SDL API functions |
miruga27 | 0:dda4f4550403 | 26 | */ |
miruga27 | 0:dda4f4550403 | 27 | |
miruga27 | 0:dda4f4550403 | 28 | #ifndef _SDL_filesystem_h |
miruga27 | 0:dda4f4550403 | 29 | #define _SDL_filesystem_h |
miruga27 | 0:dda4f4550403 | 30 | |
miruga27 | 0:dda4f4550403 | 31 | #include "SDL_stdinc.h" |
miruga27 | 0:dda4f4550403 | 32 | |
miruga27 | 0:dda4f4550403 | 33 | #include "begin_code.h" |
miruga27 | 0:dda4f4550403 | 34 | |
miruga27 | 0:dda4f4550403 | 35 | /* Set up for C function definitions, even when using C++ */ |
miruga27 | 0:dda4f4550403 | 36 | #ifdef __cplusplus |
miruga27 | 0:dda4f4550403 | 37 | extern "C" { |
miruga27 | 0:dda4f4550403 | 38 | #endif |
miruga27 | 0:dda4f4550403 | 39 | |
miruga27 | 0:dda4f4550403 | 40 | /** |
miruga27 | 0:dda4f4550403 | 41 | * \brief Get the path where the application resides. |
miruga27 | 0:dda4f4550403 | 42 | * |
miruga27 | 0:dda4f4550403 | 43 | * Get the "base path". This is the directory where the application was run |
miruga27 | 0:dda4f4550403 | 44 | * from, which is probably the installation directory, and may or may not |
miruga27 | 0:dda4f4550403 | 45 | * be the process's current working directory. |
miruga27 | 0:dda4f4550403 | 46 | * |
miruga27 | 0:dda4f4550403 | 47 | * This returns an absolute path in UTF-8 encoding, and is guaranteed to |
miruga27 | 0:dda4f4550403 | 48 | * end with a path separator ('\\' on Windows, '/' most other places). |
miruga27 | 0:dda4f4550403 | 49 | * |
miruga27 | 0:dda4f4550403 | 50 | * The pointer returned by this function is owned by you. Please call |
miruga27 | 0:dda4f4550403 | 51 | * SDL_free() on the pointer when you are done with it, or it will be a |
miruga27 | 0:dda4f4550403 | 52 | * memory leak. This is not necessarily a fast call, though, so you should |
miruga27 | 0:dda4f4550403 | 53 | * call this once near startup and save the string if you need it. |
miruga27 | 0:dda4f4550403 | 54 | * |
miruga27 | 0:dda4f4550403 | 55 | * Some platforms can't determine the application's path, and on other |
miruga27 | 0:dda4f4550403 | 56 | * platforms, this might be meaningless. In such cases, this function will |
miruga27 | 0:dda4f4550403 | 57 | * return NULL. |
miruga27 | 0:dda4f4550403 | 58 | * |
miruga27 | 0:dda4f4550403 | 59 | * \return String of base dir in UTF-8 encoding, or NULL on error. |
miruga27 | 0:dda4f4550403 | 60 | * |
miruga27 | 0:dda4f4550403 | 61 | * \sa SDL_GetPrefPath |
miruga27 | 0:dda4f4550403 | 62 | */ |
miruga27 | 0:dda4f4550403 | 63 | extern DECLSPEC char *SDLCALL SDL_GetBasePath(void); |
miruga27 | 0:dda4f4550403 | 64 | |
miruga27 | 0:dda4f4550403 | 65 | /** |
miruga27 | 0:dda4f4550403 | 66 | * \brief Get the user-and-app-specific path where files can be written. |
miruga27 | 0:dda4f4550403 | 67 | * |
miruga27 | 0:dda4f4550403 | 68 | * Get the "pref dir". This is meant to be where users can write personal |
miruga27 | 0:dda4f4550403 | 69 | * files (preferences and save games, etc) that are specific to your |
miruga27 | 0:dda4f4550403 | 70 | * application. This directory is unique per user, per application. |
miruga27 | 0:dda4f4550403 | 71 | * |
miruga27 | 0:dda4f4550403 | 72 | * This function will decide the appropriate location in the native filesystem, |
miruga27 | 0:dda4f4550403 | 73 | * create the directory if necessary, and return a string of the absolute |
miruga27 | 0:dda4f4550403 | 74 | * path to the directory in UTF-8 encoding. |
miruga27 | 0:dda4f4550403 | 75 | * |
miruga27 | 0:dda4f4550403 | 76 | * On Windows, the string might look like: |
miruga27 | 0:dda4f4550403 | 77 | * "C:\\Users\\bob\\AppData\\Roaming\\My Company\\My Program Name\\" |
miruga27 | 0:dda4f4550403 | 78 | * |
miruga27 | 0:dda4f4550403 | 79 | * On Linux, the string might look like: |
miruga27 | 0:dda4f4550403 | 80 | * "/home/bob/.local/share/My Program Name/" |
miruga27 | 0:dda4f4550403 | 81 | * |
miruga27 | 0:dda4f4550403 | 82 | * On Mac OS X, the string might look like: |
miruga27 | 0:dda4f4550403 | 83 | * "/Users/bob/Library/Application Support/My Program Name/" |
miruga27 | 0:dda4f4550403 | 84 | * |
miruga27 | 0:dda4f4550403 | 85 | * (etc.) |
miruga27 | 0:dda4f4550403 | 86 | * |
miruga27 | 0:dda4f4550403 | 87 | * You specify the name of your organization (if it's not a real organization, |
miruga27 | 0:dda4f4550403 | 88 | * your name or an Internet domain you own might do) and the name of your |
miruga27 | 0:dda4f4550403 | 89 | * application. These should be untranslated proper names. |
miruga27 | 0:dda4f4550403 | 90 | * |
miruga27 | 0:dda4f4550403 | 91 | * Both the org and app strings may become part of a directory name, so |
miruga27 | 0:dda4f4550403 | 92 | * please follow these rules: |
miruga27 | 0:dda4f4550403 | 93 | * |
miruga27 | 0:dda4f4550403 | 94 | * - Try to use the same org string (including case-sensitivity) for |
miruga27 | 0:dda4f4550403 | 95 | * all your applications that use this function. |
miruga27 | 0:dda4f4550403 | 96 | * - Always use a unique app string for each one, and make sure it never |
miruga27 | 0:dda4f4550403 | 97 | * changes for an app once you've decided on it. |
miruga27 | 0:dda4f4550403 | 98 | * - Unicode characters are legal, as long as it's UTF-8 encoded, but... |
miruga27 | 0:dda4f4550403 | 99 | * - ...only use letters, numbers, and spaces. Avoid punctuation like |
miruga27 | 0:dda4f4550403 | 100 | * "Game Name 2: Bad Guy's Revenge!" ... "Game Name 2" is sufficient. |
miruga27 | 0:dda4f4550403 | 101 | * |
miruga27 | 0:dda4f4550403 | 102 | * This returns an absolute path in UTF-8 encoding, and is guaranteed to |
miruga27 | 0:dda4f4550403 | 103 | * end with a path separator ('\\' on Windows, '/' most other places). |
miruga27 | 0:dda4f4550403 | 104 | * |
miruga27 | 0:dda4f4550403 | 105 | * The pointer returned by this function is owned by you. Please call |
miruga27 | 0:dda4f4550403 | 106 | * SDL_free() on the pointer when you are done with it, or it will be a |
miruga27 | 0:dda4f4550403 | 107 | * memory leak. This is not necessarily a fast call, though, so you should |
miruga27 | 0:dda4f4550403 | 108 | * call this once near startup and save the string if you need it. |
miruga27 | 0:dda4f4550403 | 109 | * |
miruga27 | 0:dda4f4550403 | 110 | * You should assume the path returned by this function is the only safe |
miruga27 | 0:dda4f4550403 | 111 | * place to write files (and that SDL_GetBasePath(), while it might be |
miruga27 | 0:dda4f4550403 | 112 | * writable, or even the parent of the returned path, aren't where you |
miruga27 | 0:dda4f4550403 | 113 | * should be writing things). |
miruga27 | 0:dda4f4550403 | 114 | * |
miruga27 | 0:dda4f4550403 | 115 | * Some platforms can't determine the pref path, and on other |
miruga27 | 0:dda4f4550403 | 116 | * platforms, this might be meaningless. In such cases, this function will |
miruga27 | 0:dda4f4550403 | 117 | * return NULL. |
miruga27 | 0:dda4f4550403 | 118 | * |
miruga27 | 0:dda4f4550403 | 119 | * \param org The name of your organization. |
miruga27 | 0:dda4f4550403 | 120 | * \param app The name of your application. |
miruga27 | 0:dda4f4550403 | 121 | * \return UTF-8 string of user dir in platform-dependent notation. NULL |
miruga27 | 0:dda4f4550403 | 122 | * if there's a problem (creating directory failed, etc). |
miruga27 | 0:dda4f4550403 | 123 | * |
miruga27 | 0:dda4f4550403 | 124 | * \sa SDL_GetBasePath |
miruga27 | 0:dda4f4550403 | 125 | */ |
miruga27 | 0:dda4f4550403 | 126 | extern DECLSPEC char *SDLCALL SDL_GetPrefPath(const char *org, const char *app); |
miruga27 | 0:dda4f4550403 | 127 | |
miruga27 | 0:dda4f4550403 | 128 | /* Ends C function definitions when using C++ */ |
miruga27 | 0:dda4f4550403 | 129 | #ifdef __cplusplus |
miruga27 | 0:dda4f4550403 | 130 | } |
miruga27 | 0:dda4f4550403 | 131 | #endif |
miruga27 | 0:dda4f4550403 | 132 | #include "close_code.h" |
miruga27 | 0:dda4f4550403 | 133 | |
miruga27 | 0:dda4f4550403 | 134 | #endif /* _SDL_system_h */ |
miruga27 | 0:dda4f4550403 | 135 | |
miruga27 | 0:dda4f4550403 | 136 | /* vi: set ts=4 sw=4 expandtab: */ |