Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Latest commit

 

History

History
82 lines (72 loc) · 1.97 KB

SDL_winrtpaths.cpp

File metadata and controls

82 lines (72 loc) · 1.97 KB
 
1
2
3
4
5
6
7
8
9
/* TODO, WinRT: include copyright info in SDL_winrtpaths.cpp
TODO, WinRT: add note to SDL_winrtpaths.cpp mentioning that /ZW must be used when compiling the file
*/
#include "SDL_config.h"
#ifdef __WINRT__
extern "C" {
Feb 3, 2013
Feb 3, 2013
10
11
#include "SDL_error.h"
#include "SDL_stdinc.h"
12
13
14
15
16
17
#include "SDL_system.h"
#include "../windows/SDL_windows.h"
}
using namespace Windows::Storage;
Feb 3, 2013
Feb 3, 2013
18
19
static const wchar_t *
WINRT_CopySystemPath(Windows::Storage::StorageFolder ^ folder)
Feb 3, 2013
Feb 3, 2013
21
22
23
24
25
26
27
28
29
30
31
const wchar_t * srcPath = folder->Path->Data();
const size_t srcPathLen = SDL_wcslen(srcPath);
wchar_t * destPath = (wchar_t *) SDL_calloc(srcPathLen + 1, sizeof(wchar_t));
if (!destPath) {
SDL_OutOfMemory();
return NULL;
}
SDL_wcslcpy(destPath, srcPath, srcPathLen + 1);
return destPath;
}
Feb 3, 2013
Feb 3, 2013
32
33
34
35
36
37
38
39
40
41
extern "C" const wchar_t *
SDL_WinRTGetInstalledLocationPath()
{
static const wchar_t * path = nullptr;
if (!path) {
path = WINRT_CopySystemPath(Windows::ApplicationModel::Package::Current->InstalledLocation);
}
return path;
}
Feb 3, 2013
Feb 3, 2013
42
43
44
45
extern "C" const wchar_t *
SDL_WinRTGetLocalFolderPath()
{
static const wchar_t * path = nullptr;
Feb 3, 2013
Feb 3, 2013
47
path = WINRT_CopySystemPath(ApplicationData::Current->LocalFolder);
48
49
50
51
}
return path;
}
Feb 3, 2013
Feb 3, 2013
52
53
extern "C" const wchar_t *
SDL_WinRTGetRoamingFolderPath()
Feb 3, 2013
Feb 3, 2013
55
56
57
58
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
SDL_Unsupported();
return NULL;
#else
Feb 3, 2013
Feb 3, 2013
59
static const wchar_t * path = nullptr;
Feb 3, 2013
Feb 3, 2013
61
path = WINRT_CopySystemPath(ApplicationData::Current->RoamingFolder);
Feb 3, 2013
Feb 3, 2013
64
#endif
Feb 3, 2013
Feb 3, 2013
67
68
extern "C" const wchar_t *
SDL_WinRTGetTemporaryFolderPath()
Feb 3, 2013
Feb 3, 2013
70
71
72
73
#if WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP
SDL_Unsupported();
return NULL;
#else
Feb 3, 2013
Feb 3, 2013
74
static const wchar_t * path = nullptr;
Feb 3, 2013
Feb 3, 2013
76
path = WINRT_CopySystemPath(ApplicationData::Current->TemporaryFolder);
Feb 3, 2013
Feb 3, 2013
79
#endif
80
81
82
}
#endif /* __WINRT__ */