-
-
Notifications
You must be signed in to change notification settings - Fork 229
/
Copy pathfilesystem.go
50 lines (40 loc) · 1.29 KB
/
filesystem.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package sdl
/*
#include "sdl_wrapper.h"
#if !(SDL_VERSION_ATLEAST(2,0,1))
#if defined(WARN_OUTDATED)
#pragma message("SDL_GetBasePath is not supported before SDL 2.0.1")
#endif
static inline char* SDL_GetBasePath()
{
return NULL;
}
#if defined(WARN_OUTDATED)
#pragma message("SDL_GetPrefPath is not supported before SDL 2.0.1")
#endif
static inline char* SDL_GetPrefPath(const char *org, const char *app)
{
return NULL;
}
#endif
*/
import "C"
import "unsafe"
// GetBasePath returns the directory where the application was run from. This is where the application data directory is.
// (https://wiki.libsdl.org/SDL2/SDL_GetBasePath)
func GetBasePath() string {
_val := C.SDL_GetBasePath()
defer C.SDL_free(unsafe.Pointer(_val))
return C.GoString(_val)
}
// GetPrefPath returns the "pref dir". This is meant to be where the application can write personal files (Preferences and save games, etc.) that are specific to the application. This directory is unique per user and per application.
// (https://wiki.libsdl.org/SDL2/SDL_GetPrefPath)
func GetPrefPath(org, app string) string {
_org := C.CString(org)
_app := C.CString(app)
defer C.free(unsafe.Pointer(_org))
defer C.free(unsafe.Pointer(_app))
_val := C.SDL_GetPrefPath(_org, _app)
defer C.SDL_free(unsafe.Pointer(_val))
return C.GoString(_val)
}