diff options
Diffstat (limited to 'src/libutil')
-rw-r--r-- | src/libutil/file-system.cc | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/src/libutil/file-system.cc b/src/libutil/file-system.cc index f0199d36f..e2319ec59 100644 --- a/src/libutil/file-system.cc +++ b/src/libutil/file-system.cc @@ -21,22 +21,14 @@ Path absPath(Path path, std::optional<PathView> dir, bool resolveSymlinks) { if (path.empty() || path[0] != '/') { if (!dir) { -#ifdef __GNU__ - /* GNU (aka. GNU/Hurd) doesn't have any limitation on path - lengths and doesn't define `PATH_MAX'. */ - char *buf = getcwd(NULL, 0); - if (buf == NULL) -#else char buf[PATH_MAX]; - if (!getcwd(buf, sizeof(buf))) -#endif + if (!getcwd(buf, sizeof(buf))) { throw SysError("cannot get cwd"); + } path = concatStrings(buf, "/", path); -#ifdef __GNU__ - free(buf); -#endif - } else + } else { path = concatStrings(*dir, "/", path); + } } return canonPath(path, resolveSymlinks); } |