21 #include "../../SDL_internal.h" 23 #ifdef SDL_FILESYSTEM_UNIX 33 #include <sys/types.h> 36 #if defined(__FREEBSD__) || defined(__OPENBSD__) 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 };
94 #if defined(__OPENBSD__) 97 const int mib[] = { CTL_KERN, KERN_PROC_ARGS, getpid(), KERN_PROC_ARGV };
98 if (sysctl(mib, 4,
NULL, &len,
NULL, 0) != -1) {
104 sysctl(mib, 4, retvalargs, &len,
NULL, 0);
107 realpath(retvalargs[0], retval);
112 #if defined(__SOLARIS__) 113 const char *path = getexecname();
114 if ((path !=
NULL) && (path[0] ==
'/')) {
124 if (!retval && (
access(
"/proc", F_OK) == 0)) {
125 #if defined(__FREEBSD__) 126 retval = readSymLink(
"/proc/curproc/file");
127 #elif defined(__NETBSD__) 128 retval = readSymLink(
"/proc/curproc/exe");
130 retval = readSymLink(
"/proc/self/exe");
132 if (retval ==
NULL) {
137 (
unsigned long long) getpid());
138 if ( (rc > 0) && (rc <
sizeof(
path)) ) {
139 retval = readSymLink(path);
147 if (retval !=
NULL) {
157 if (retval !=
NULL) {
159 char *ptr = (
char *)
SDL_realloc(retval, strlen(retval) + 1);
177 const char *envr =
SDL_getenv(
"XDG_DATA_HOME");
188 SDL_SetError(
"neither XDG_DATA_HOME nor HOME environment is set");
191 append =
"/.local/share/";
197 if (envr[len - 1] ==
'/')
207 SDL_snprintf(retval, len,
"%s%s%s/%s/", envr, append, org, app);
209 for (ptr = retval+1; *
ptr; ptr++) {
212 if (mkdir(retval, 0700) != 0 && errno != EEXIST)
217 if (mkdir(retval, 0700) != 0 && errno != EEXIST) {
219 SDL_SetError(
"Couldn't create directory '%s': '%s'", retval, strerror(errno));
set set set set set set set set set set set set set set set set set set set set *set set set macro pixldst op &r &cond WK op &r &cond WK op &r &cond WK else op &m &cond &ia op &r &cond WK else op &m &cond &ia elseif elseif else error unsupported base if elseif elseif else error unsupported unaligned pixldst unaligned endm macro pixst base base else pixldst base endif endm macro PF ptr
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.