21 #include "../../SDL_internal.h" 23 #ifdef SDL_FILESYSTEM_UNIX 33 #include <sys/types.h> 37 #include <sys/sysctl.h> 45 readSymLink(
const char *
path)
61 rc = readlink(path, retval, len);
64 }
else if (rc < len) {
82 #if defined(__FREEBSD__) 83 char fullpath[PATH_MAX];
84 size_t buflen =
sizeof (fullpath);
85 const int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 };
93 #elif defined(__SOLARIS__) 94 const char *path = getexecname();
95 if ((path !=
NULL) && (path[0] ==
'/')) {
105 if (!retval && (
access(
"/proc", F_OK) == 0)) {
106 #if defined(__FREEBSD__) 107 retval = readSymLink(
"/proc/curproc/file");
108 #elif defined(__NETBSD__) 109 retval = readSymLink(
"/proc/curproc/exe");
111 retval = readSymLink(
"/proc/self/exe");
113 if (retval ==
NULL) {
118 (
unsigned long long) getpid());
119 if ( (rc > 0) && (rc <
sizeof(
path)) ) {
120 retval = readSymLink(path);
128 if (retval !=
NULL) {
138 if (retval !=
NULL) {
140 char *ptr = (
char *)
SDL_realloc(retval, strlen(retval) + 1);
158 const char *envr =
SDL_getenv(
"XDG_DATA_HOME");
169 SDL_SetError(
"neither XDG_DATA_HOME nor HOME environment is set");
172 append =
"/.local/share/";
178 if (envr[len - 1] ==
'/')
188 SDL_snprintf(retval, len,
"%s%s%s/%s/", envr, append, org, app);
190 for (ptr = retval+1; *ptr; ptr++) {
193 if (mkdir(retval, 0700) != 0 && errno != EEXIST)
198 if (mkdir(retval, 0700) != 0 && errno != EEXIST) {
200 SDL_SetError(
"Couldn't create directory '%s': '%s'", retval, strerror(errno));
GLuint GLint GLboolean GLint GLenum access
#define SDL_OutOfMemory()
Include file for filesystem SDL API functions.
#define SDL_arraysize(array)
GLsizei const GLchar *const * path
char * SDL_GetBasePath(void)
Get the path where the application resides.