aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Mark Loeser <halcy0n@gentoo.org> 2006-01-26 21:37:13 +0000
committerAvatar Mark Loeser <halcy0n@gentoo.org> 2006-01-26 21:37:13 +0000
commit192bbcfc2568b8f1123a77f452e29ed370af4a45 (patch)
tree9eae0ab4b9e4a603a530a48c8160b94b785b875b
parent18ffe63eb8b91364a75125decd595603b2000ff3 (diff)
downloadpaludis-192bbcfc2568b8f1123a77f452e29ed370af4a45.tar.gz
paludis-192bbcfc2568b8f1123a77f452e29ed370af4a45.tar.xz
Need to call stat() when we use FSEntry::operator/=. Added testcase for this bug.
-rw-r--r--paludis/fs_entry.cc30
-rw-r--r--paludis/fs_entry.hh2
-rw-r--r--paludis/fs_entry_TEST.cc2
3 files changed, 23 insertions, 11 deletions
diff --git a/paludis/fs_entry.cc b/paludis/fs_entry.cc
index 7411e52..fa8356d 100644
--- a/paludis/fs_entry.cc
+++ b/paludis/fs_entry.cc
@@ -45,19 +45,10 @@ FSError::FSError(const std::string & message) throw () :
FSEntry::FSEntry(const std::string & path) :
ComparisonPolicyType(&FSEntry::_path),
_path(path),
- _stat_info(new struct stat),
- _exists(true)
+ _stat_info(new struct stat)
{
_normalise();
-
- if (0 != stat(_path.c_str(), _stat_info.raw_pointer()))
- {
- if (errno != ENOENT)
- throw FSError("Error running stat() on '" + stringify(_path) + "': "
- + strerror(errno));
-
- _exists = false;
- }
+ _stat();
}
FSEntry::FSEntry(const FSEntry & other) :
@@ -102,6 +93,8 @@ FSEntry::operator/= (const FSEntry & rhs)
_path.append("/");
_path.append(rhs._path);
_normalise();
+ _stat();
+
return *this;
}
@@ -245,6 +238,21 @@ FSEntry::_normalise()
}
}
+void
+FSEntry::_stat()
+{
+ if (0 != stat(_path.c_str(), _stat_info.raw_pointer()))
+ {
+ if (errno != ENOENT)
+ throw FSError("Error running stat() on '" + stringify(_path) + "': "
+ + strerror(errno));
+
+ _exists = false;
+ }
+ else
+ _exists = true;
+}
+
std::string
FSEntry::basename() const
{
diff --git a/paludis/fs_entry.hh b/paludis/fs_entry.hh
index 3243047..78fa1c5 100644
--- a/paludis/fs_entry.hh
+++ b/paludis/fs_entry.hh
@@ -70,6 +70,8 @@ namespace paludis
void _normalise();
+ void _stat();
+
public:
/**
* Constructor, from a path.
diff --git a/paludis/fs_entry_TEST.cc b/paludis/fs_entry_TEST.cc
index c7cb456..898e074 100644
--- a/paludis/fs_entry_TEST.cc
+++ b/paludis/fs_entry_TEST.cc
@@ -71,6 +71,8 @@ namespace test_cases
{
FSEntry d("fs_entry_TEST_dir");
TEST_CHECK(d.is_directory());
+ d /= "all_perms";
+ TEST_CHECK(d.is_regular_file());
FSEntry f("fs_entry_TEST_dir/symlink_to_dir_a/file_in_a");
TEST_CHECK(f.is_regular_file());