src/filesystem/unix/SDL_sysfilesystem.c
changeset 7668 66da4242ce53
parent 7667 be1cc6f55840
child 7692 e1036c58fac7
equal deleted inserted replaced
7667:be1cc6f55840 7668:66da4242ce53
    24 
    24 
    25 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
    25 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
    26 /* System dependent filesystem routines                                */
    26 /* System dependent filesystem routines                                */
    27 
    27 
    28 #include <unistd.h>
    28 #include <unistd.h>
       
    29 #include <sys/stat.h>
       
    30 #include <sys/types.h>
    29 
    31 
    30 #include "SDL_error.h"
    32 #include "SDL_error.h"
    31 #include "SDL_stdinc.h"
    33 #include "SDL_stdinc.h"
    32 #include "SDL_filesystem.h"
    34 #include "SDL_filesystem.h"
    33 
    35 
    34 static char *readSymLink(const char *path)
    36 static char *
       
    37 readSymLink(const char *path)
    35 {
    38 {
    36     char *retval = NULL;
    39     char *retval = NULL;
    37     ssize_t len = 64;
    40     ssize_t len = 64;
    38     ssize_t rc = -1;
    41     ssize_t rc = -1;
    39 
    42 
    69 SDL_GetBasePath(void)
    72 SDL_GetBasePath(void)
    70 {
    73 {
    71     char *retval = NULL;
    74     char *retval = NULL;
    72 
    75 
    73     /* is a Linux-style /proc filesystem available? */
    76     /* is a Linux-style /proc filesystem available? */
    74     if (access("/proc", F_OK) {
    77     if (access("/proc", F_OK) == 0) {
    75         retval = readSymLink("/proc/self/exe");
    78         retval = readSymLink("/proc/self/exe");
    76         if (retval == NULL) {
    79         if (retval == NULL) {
    77             /* older kernels don't have /proc/self ... try PID version... */
    80             /* older kernels don't have /proc/self ... try PID version... */
    78             char path[64];
    81             char path[64];
    79             const int rc = (int) SDL_snprintf(path, sizeof(path),
    82             const int rc = (int) SDL_snprintf(path, sizeof(path),