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