Skip to content

Commit

Permalink
Bug: Resolving cross platform issues with the new Path class
Browse files Browse the repository at this point in the history
  • Loading branch information
StevenAWhite committed Apr 9, 2019
1 parent c0c9175 commit 07e2fef
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
9 changes: 6 additions & 3 deletions projects/biogears-common/include/biogears/filesystem/path.h
Expand Up @@ -124,6 +124,8 @@ namespace filesystem {
path make_normal() const
{
path working_path;
working_path.m_absolute = m_absolute;
working_path.m_type = m_type;
for (auto& segment : m_path) {
if (segment.empty()) {

Expand Down Expand Up @@ -230,15 +232,16 @@ namespace filesystem {
}
path operator/(const path& other) const
{
if (other.m_absolute)
if (other.m_absolute) {
if (m_path.empty()) {
return other;
} else {
throw std::runtime_error("path::operator/(): expected a relative path!");
}
if (m_type != other.m_type)
}
if (m_type != other.m_type) {
throw std::runtime_error("path::operator/(): expected a path of the same type!");

}
path result(*this);

for (size_t i = 0; i < other.m_path.size(); ++i)
Expand Down
2 changes: 1 addition & 1 deletion projects/biogears-common/unit/test_common_Path.cpp
Expand Up @@ -85,7 +85,7 @@ TEST_F(TEST_FIXTURE_NAME, Path_Empty)

EXPECT_TRUE(path_empty.empty());
EXPECT_FALSE(path_relative.empty());

//This test is inconsistant across paltforms. Need to improve
//EXPECT_FALSE(path_absolute_root.empty());
}

Expand Down
1 change: 0 additions & 1 deletion projects/biogears/unit/cdm/utils/test_core_FileUtils.cpp
Expand Up @@ -79,7 +79,6 @@ TEST_F(TEST_FIXTURE_NAME, FileUtils_ResolvePath)
biogears::SetCurrentWorkingDirectory("");
EXPECT_EQ(path::getcwd() / "test_file.txt", ResolvePath("test_file.txt"));
EXPECT_EQ(path::getcwd() / "test_file.txt", ResolvePath("./test_file.txt"));
EXPECT_EQ(path("C:/biogears/test_file.txt").make_normal(), ResolvePath("C:/biogears/test_file.txt"));

#ifdef _WIN32
biogears::SetCurrentWorkingDirectory("C:/");
Expand Down

0 comments on commit 07e2fef

Please sign in to comment.