src/filesystem/winrt/SDL_sysfilesystem.cpp
author David Ludwig <dludwig@pobox.com>
Mon, 10 Mar 2014 21:21:35 -0400
changeset 8600 092802455aed
parent 8582 c3e9a2b93517
child 8616 ec011c16e2fd
permissions -rw-r--r--
build fixes for most WinRT-related files Still TODO: getting the D3D11 renderer back up and running in VC 2012.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
     1
/* TODO, WinRT: include copyright info in SDL_winrtpaths.cpp
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
     2
   TODO, WinRT: remove the need to compile this with C++/CX (/ZW) extensions, and if possible, without C++ at all
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
     3
*/
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
     4
8600
092802455aed build fixes for most WinRT-related files
David Ludwig <dludwig@pobox.com>
parents: 8582
diff changeset
     5
#include "../../SDL_internal.h"
8582
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
     6
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
     7
#ifdef __WINRT__
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
     8
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
     9
extern "C" {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    10
#include "SDL_filesystem.h"
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    11
#include "SDL_error.h"
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    12
#include "SDL_stdinc.h"
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    13
#include "SDL_system.h"
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    14
#include "../../core/windows/SDL_windows.h"
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    15
}
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    16
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    17
#include <string>
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    18
#include <unordered_map>
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    19
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    20
using namespace std;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    21
using namespace Windows::Storage;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    22
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    23
extern "C" const wchar_t *
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    24
SDL_WinRTGetFSPathUNICODE(SDL_WinRT_Path pathType)
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    25
{
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    26
    switch (pathType) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    27
        case SDL_WINRT_PATH_INSTALLED_LOCATION:
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    28
        {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    29
            static wstring path;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    30
            if (path.empty()) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    31
                path = Windows::ApplicationModel::Package::Current->InstalledLocation->Path->Data();
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    32
            }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    33
            return path.c_str();
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    34
        }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    35
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    36
        case SDL_WINRT_PATH_LOCAL_FOLDER:
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    37
        {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    38
            static wstring path;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    39
            if (path.empty()) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    40
                path = ApplicationData::Current->LocalFolder->Path->Data();
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    41
            }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    42
            return path.c_str();
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    43
        }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    44
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    45
#if WINAPI_FAMILY != WINAPI_FAMILY_PHONE_APP
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    46
        case SDL_WINRT_PATH_ROAMING_FOLDER:
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    47
        {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    48
            static wstring path;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    49
            if (path.empty()) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    50
                path = ApplicationData::Current->RoamingFolder->Path->Data();
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    51
            }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    52
            return path.c_str();
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    53
        }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    54
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    55
        case SDL_WINRT_PATH_TEMP_FOLDER:
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    56
        {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    57
            static wstring path;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    58
            if (path.empty()) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    59
                path = ApplicationData::Current->TemporaryFolder->Path->Data();
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    60
            }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    61
            return path.c_str();
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    62
        }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    63
#endif
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    64
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    65
        default:
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    66
            break;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    67
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    68
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    69
    SDL_Unsupported();
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    70
    return NULL;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    71
}
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    72
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    73
extern "C" const char *
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    74
SDL_WinRTGetFSPathUTF8(SDL_WinRT_Path pathType)
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    75
{
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    76
    typedef unordered_map<SDL_WinRT_Path, string> UTF8PathMap;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    77
    static UTF8PathMap utf8Paths;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    78
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    79
    UTF8PathMap::iterator searchResult = utf8Paths.find(pathType);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    80
    if (searchResult != utf8Paths.end()) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    81
        return searchResult->second.c_str();
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    82
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    83
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    84
    const wchar_t * ucs2Path = SDL_WinRTGetFSPathUNICODE(pathType);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    85
    if (!ucs2Path) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    86
        return NULL;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    87
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    88
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    89
    char * utf8Path = WIN_StringToUTF8(ucs2Path);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    90
    utf8Paths[pathType] = utf8Path;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    91
    SDL_free(utf8Path);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    92
    return utf8Paths[pathType].c_str();
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    93
}
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    94
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    95
extern "C" char *
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    96
SDL_GetBasePath(void)
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    97
{
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    98
    const char * srcPath = SDL_WinRTGetFSPathUTF8(SDL_WINRT_PATH_INSTALLED_LOCATION);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
    99
    size_t destPathLen;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
   100
    char * destPath = NULL;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
   101
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
   102
    if (!srcPath) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
   103
        SDL_SetError("Couldn't locate our basepath: %s", SDL_GetError());
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
   104
        return NULL;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
   105
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
   106
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
   107
    destPathLen = SDL_strlen(srcPath) + 2;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
   108
    destPath = (char *) SDL_malloc(destPathLen);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
   109
    if (!destPath) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
   110
        SDL_OutOfMemory();
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
   111
        return NULL;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
   112
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
   113
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
   114
    SDL_snprintf(destPath, destPathLen, "%s\\", srcPath);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
   115
    return destPath;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
   116
}
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
   117
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
   118
extern "C" char *
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
   119
SDL_GetPrefPath(const char *org, const char *app)
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
   120
{
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
   121
    /* WinRT note: The 'SHGetFolderPath' API that is used in Windows 7 and
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
   122
     * earlier is not available on WinRT or Windows Phone.  WinRT provides
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
   123
     * a similar API, but SHGetFolderPath can't be called, at least not
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
   124
     * without violating Microsoft's app-store requirements.
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
   125
     */
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
   126
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
   127
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
   128
    /* A 'Roaming' folder is not available in Windows Phone 8, however a 'Local' folder is. */
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
   129
    const char * srcPath = SDL_WinRTGetFSPathUTF8(SDL_WINRT_PATH_LOCAL_FOLDER);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
   130
#else
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
   131
    /* A 'Roaming' folder is available on Windows 8 and 8.1.  Use that. */
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
   132
    const char * srcPath = SDL_WinRTGetFSPathUTF8(SDL_WINRT_PATH_ROAMING_FOLDER);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
   133
#endif
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
   134
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
   135
    size_t destPathLen;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
   136
    char * destPath = NULL;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
   137
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
   138
    if (!srcPath) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
   139
        SDL_SetError("Couldn't locate our basepath: %s", SDL_GetError());
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
   140
        return NULL;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
   141
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
   142
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
   143
    destPathLen = SDL_strlen(srcPath) + SDL_strlen(org) + SDL_strlen(app) + 4;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
   144
    destPath = (char *) SDL_malloc(destPathLen);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
   145
    if (!destPath) {
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
   146
        SDL_OutOfMemory();
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
   147
        return NULL;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
   148
    }
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
   149
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
   150
    SDL_snprintf(destPath, destPathLen, "%s\\%s\\%s\\", srcPath, org, app);
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
   151
    return destPath;
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
   152
}
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
   153
c3e9a2b93517 Fixed line endings on WinRT source code
Sam Lantinga <slouken@libsdl.org>
parents: 8539
diff changeset
   154
#endif /* __WINRT__ */