diff --git a/src/Filesystem.cc b/src/Filesystem.cc index 874fba44..b0a4d5f6 100644 --- a/src/Filesystem.cc +++ b/src/Filesystem.cc @@ -135,7 +135,14 @@ std::string common::copyToUnixPath(const std::string &_path) ///////////////////////////////////////////////// std::string common::absPath(const std::string &_path) { - return fs::absolute(_path).string(); + std::error_code ec; + auto path = fs::absolute(_path, ec); + if (!fsWarn("absPath", ec)) + { + path = ""; + } + + return path.string(); } ///////////////////////////////////////////////// diff --git a/src/Filesystem_TEST.cc b/src/Filesystem_TEST.cc index 86a72c8a..1fb13e2a 100644 --- a/src/Filesystem_TEST.cc +++ b/src/Filesystem_TEST.cc @@ -636,3 +636,13 @@ TEST_F(FilesystemTest, separator) EXPECT_EQ("\\", gz::common::separator("")); #endif } + +///////////////////////////////////////////////// +TEST_F(FilesystemTest, empty) +{ +#ifdef __APPLE__ + EXPECT_EQ(common::absPath(""), gz::common::cwd() + "/"); +#else + EXPECT_EQ(common::absPath(""), ""); +#endif +}