#include <util/path.hpp>
#include <util/string.hpp>
-#include <limits.h> // NOLINT: PATH_MAX is defined in limits.h
-
#ifdef HAVE_DIRENT_H
# include <dirent.h>
#endif
std::string
get_actual_cwd()
{
- char buffer[PATH_MAX];
- if (getcwd(buffer, sizeof(buffer))) {
-#ifndef _WIN32
- return buffer;
-#else
- std::string cwd = buffer;
- std::replace(cwd.begin(), cwd.end(), '\\', '/');
- return cwd;
+ std::error_code ec;
+ auto cwd = fs::current_path(ec).string();
+#ifdef _WIN32
+ std::replace(cwd.begin(), cwd.end(), '\\', '/');
#endif
- } else {
- return {};
- }
+ return cwd;
}
std::string
-// Copyright (C) 2021 Joel Rosdahl and other contributors
+// Copyright (C) 2021-2022 Joel Rosdahl and other contributors
//
// See doc/AUTHORS.adoc for a complete list of contributors.
//
# define STDOUT_FILENO 1
# define STDERR_FILENO 2
-# ifdef _MSC_VER
-# define PATH_MAX MAX_PATH
-# endif // _MSC_VER
-
// From:
// http://mesos.apache.org/api/latest/c++/3rdparty_2stout_2include_2stout_2windows_8hpp_source.html
# ifdef _MSC_VER
// Protect against incidental use of MinGW execv.
# define execv(a, b) do_not_call_execv_on_windows
-# ifdef _MSC_VER
-# define PATH_MAX MAX_PATH
-# endif
-
# ifdef _MSC_VER
# define DLLIMPORT __declspec(dllimport)
# else