Skip to content

Commit

Permalink
Address PR feedback
Browse files Browse the repository at this point in the history
Signed-off-by: Louise Poubel <louise@openrobotics.org>
  • Loading branch information
chapulina committed Mar 3, 2022
1 parent 3e101f8 commit d453ab6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/Filesystem.cc
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,11 @@ bool ignition::common::chdir(const std::string &_dir)
/////////////////////////////////////////////////
std::string ignition::common::basename(const std::string &_path)
{
fs::path p = fs::path(_path);
fs::path p(_path);
p /= "FOO.TXT";
p = p.lexically_normal();
p = p.parent_path();
return p.filename().string().empty() ?
return p.filename().string().empty() ?
std::string{fs::path::preferred_separator} : p.filename().string();
}

Expand Down
6 changes: 5 additions & 1 deletion src/Filesystem_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,11 @@ TEST_F(FilesystemTest, decomposition)
{
std::string absolute = joinPaths("", "home", "bob", "foo");
EXPECT_EQ(basename(absolute), "foo");
#ifndef _WIN32
EXPECT_EQ(parentPath(absolute), "/home/bob");
#else
EXPECT_EQ(parentPath(absolute), "\\home\\bob");
#endif

std::string relative = joinPaths("baz", "foobar");
EXPECT_EQ(basename(relative), "foobar");
Expand Down Expand Up @@ -626,7 +630,7 @@ TEST_F(FilesystemTest, separator)
#ifndef _WIN32
EXPECT_EQ("/", ignition::common::separator(""));
#else
EXPECT_EQ("\\", ignition::common::separator(""));
EXPECT_EQ("\\", ignition::common::separator(""));
#endif
}

Expand Down

0 comments on commit d453ab6

Please sign in to comment.