aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Mark Loeser <halcy0n@gentoo.org> 2006-02-07 20:39:29 +0000
committerAvatar Mark Loeser <halcy0n@gentoo.org> 2006-02-07 20:39:29 +0000
commit7a43c2e8602afa9eaf174c43181ada24ef87f3f5 (patch)
tree6e215a0115f22196d7ac4008b379c872021909a2
parent1a7690a561d43a4ed200ce99723f466d3f39be90 (diff)
downloadpaludis-7a43c2e8602afa9eaf174c43181ada24ef87f3f5.tar.gz
paludis-7a43c2e8602afa9eaf174c43181ada24ef87f3f5.tar.xz
Make FSEntry::dirname() return a FSEntry
-rw-r--r--paludis/fs_entry.cc6
-rw-r--r--paludis/fs_entry.hh2
-rw-r--r--paludis/fs_entry_TEST.cc10
3 files changed, 9 insertions, 9 deletions
diff --git a/paludis/fs_entry.cc b/paludis/fs_entry.cc
index e1d61c6..86df8ff 100644
--- a/paludis/fs_entry.cc
+++ b/paludis/fs_entry.cc
@@ -269,13 +269,13 @@ FSEntry::basename() const
return _path.substr(_path.rfind('/') + 1);
}
-std::string
+FSEntry
FSEntry::dirname() const
{
if (_path == "/")
- return _path;
+ return FSEntry(_path);
- return _path.substr(0, _path.rfind('/'));
+ return FSEntry(_path.substr(0, _path.rfind('/')));
}
FSEntry
diff --git a/paludis/fs_entry.hh b/paludis/fs_entry.hh
index ac24554..d576b5a 100644
--- a/paludis/fs_entry.hh
+++ b/paludis/fs_entry.hh
@@ -188,7 +188,7 @@ namespace paludis
/**
* Return the first part of our path (eg '/foo/bar' => '/foo').
*/
- std::string dirname() const;
+ FSEntry dirname() const;
/**
* Return the canonicalised version of our path.
diff --git a/paludis/fs_entry_TEST.cc b/paludis/fs_entry_TEST.cc
index 075755f..4f0d0da 100644
--- a/paludis/fs_entry_TEST.cc
+++ b/paludis/fs_entry_TEST.cc
@@ -180,15 +180,15 @@ namespace test_cases
FSEntry e("..");
TEST_CHECK(a.basename() == "bar");
- TEST_CHECK(a.dirname() == "/foo");
+ TEST_CHECK(std::string(a.dirname()) == "/foo");
TEST_CHECK(b.basename() == "cow");
- TEST_CHECK(b.dirname() == "/moo/went/the");
+ TEST_CHECK(std::string(b.dirname()) == "/moo/went/the");
TEST_CHECK(c.basename() == "/");
- TEST_CHECK(c.dirname() == "/");
+ TEST_CHECK(std::string(c.dirname()) == "/");
TEST_CHECK(d.basename() == ".");
- TEST_CHECK(d.dirname() == ".");
+ TEST_CHECK(std::string(d.dirname()) == ".");
TEST_CHECK(e.basename() == "..");
- TEST_CHECK(e.dirname() == "..");
+ TEST_CHECK(std::string(e.dirname()) == "..");
}
} test_fs_entry_dir_base_name;
}