Commit 9781f49a authored by kulvait's avatar kulvait

FIX: absolute path

parent 1515ab9d
......@@ -182,15 +182,15 @@ namespace io {
std::string getParent(const std::string& path)
{
std::string absolutePath = std::experimental::filesystem::absolute(path);
std::string absolutePath = std::experimental::filesystem::absolute(path);
// find last '/' or '\\' symbol in source string
std::string::size_type found = absolutePath.find_last_of("/\\");
if(found != std::string::npos)
{
return path.substr(0, found);
return std::experimental::filesystem::canonical(absolutePath.substr(0, found));
} else
{
return "";
return std::experimental::filesystem::canonical(".");
}
}
......
......@@ -20,3 +20,9 @@ TEST_CASE("TEST: concatenateTextFiles function.", "rawop.h")
std::string content = io::fileToString(outputFile);
REQUIRE(content == "A\nB\n");
}
TEST_CASE("TEST: absolute path.", "rawop.h")
{
std::string p = io::getParent("abc");
//LOGE << p;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment