Changeset 2262


Ignore:
Timestamp:
Jan 22, 2013, 9:46:28 PM (7 years ago)
Author:
sam
Message:

sys: check for <unistd.h> and use getcwd() properly on non-Windows systems.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/configure.ac

    r2237 r2262  
    7474
    7575AC_CHECK_HEADERS(stdio.h stdarg.h inttypes.h endian.h stdint.h getopt.h)
    76 AC_CHECK_HEADERS(fastmath.h pthread.h libutil.h util.h pty.h glob.h)
     76AC_CHECK_HEADERS(fastmath.h pthread.h libutil.h util.h pty.h glob.h unistd.h)
    7777AC_CHECK_HEADERS(sys/ioctl.h sys/ptrace.h sys/stat.h sys/syscall.h sys/user.h)
    7878AC_CHECK_HEADERS(sys/wait.h)
  • trunk/src/sys/init.cpp

    r2259 r2262  
    1111#if defined HAVE_CONFIG_H
    1212#   include "config.h"
     13#endif
     14
     15#if defined HAVE_UNISTD_H
     16#   include <unistd.h>
    1317#endif
    1418
     
    4044
    4145#if defined _WIN32
    42     char const *cwd = _getcwd(NULL, 0);
     46    char *cwd = _getcwd(NULL, 0);
     47#else
     48    char *cwd = getcwd(NULL, 0);
     49#endif
    4350    String binarydir = String(cwd ? cwd : ".") + SEPARATOR;
    44     free((void *)cwd);
    45 #else
    46     String binarydir = String(getcwd()) + SEPARATOR;
    47 #endif
     51    free(cwd);
    4852    if (argc > 0)
    4953    {
    50         char const *last_sep = strchr(argv[0], SEPARATOR);
     54        char const *last_sep = strrchr(argv[0], SEPARATOR);
    5155        if (last_sep)
    5256            binarydir = String(argv[0], last_sep - argv[0] + 1);
     
    8387        got_rootdir = true;
    8488    }
     89
     90    Log::Debug("binary dir: %s\n", &binarydir[0]);
     91    Log::Debug("root dir: %s\n", GetDataDir());
    8592}
    8693
Note: See TracChangeset for help on using the changeset viewer.