src/core/windowsrt/SDL_winrtpaths.cpp
author David Ludwig <dludwig@pobox.com>
Sun, 03 Feb 2013 13:18:31 -0500
changeset 8406 a3244b2eefcd
parent 8405 fe893b2d6f4d
child 8420 99dc85ad173c
permissions -rw-r--r--
WinRT: fixed an odd path retrieval bug
     1 /* TODO, WinRT: include copyright info in SDL_winrtpaths.cpp
     2    TODO, WinRT: add note to SDL_winrtpaths.cpp mentioning that /ZW must be used when compiling the file
     3 */
     4 
     5 #include "SDL_config.h"
     6 
     7 #ifdef __WINRT__
     8 
     9 extern "C" {
    10 #include "SDL_error.h"
    11 #include "SDL_stdinc.h"
    12 #include "SDL_system.h"
    13 #include "../windows/SDL_windows.h"
    14 }
    15 
    16 #include <string>
    17 
    18 using namespace std;
    19 using namespace Windows::Storage;
    20 
    21 extern "C" const wchar_t *
    22 SDL_WinRTGetInstalledLocationPath()
    23 {
    24     static wstring path;
    25     if (path.empty()) {
    26         path = Windows::ApplicationModel::Package::Current->InstalledLocation->Path->Data();
    27     }
    28     return path.c_str();
    29 }
    30 
    31 extern "C" const wchar_t *
    32 SDL_WinRTGetLocalFolderPath()
    33 {
    34     static wstring path;
    35     if (path.empty()) {
    36         path = ApplicationData::Current->LocalFolder->Path->Data();
    37     }
    38     return path.c_str();
    39 }
    40 
    41 extern "C" const wchar_t *
    42 SDL_WinRTGetRoamingFolderPath()
    43 {
    44 #if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
    45     SDL_Unsupported();
    46     return NULL;
    47 #else
    48     static wstring path;
    49     if (path.empty()) {
    50         path = ApplicationData::Current->RoamingFolder->Path->Data();
    51     }
    52     return path.c_str();
    53 #endif
    54 }
    55 
    56 extern "C" const wchar_t *
    57 SDL_WinRTGetTemporaryFolderPath()
    58 {
    59 #if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
    60     SDL_Unsupported();
    61     return NULL;
    62 #else
    63     static wstring path;
    64     if (path.empty()) {
    65         path = ApplicationData::Current->TemporaryFolder->Path->Data();
    66     }
    67     return path.c_str();
    68 #endif
    69 }
    70 
    71 #endif /* __WINRT__ */