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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.