aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-06-28 00:31:56 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-06-28 00:31:56 +0000
commitfe5d06be3529fcd8a11205c6d7762a329a438f3a (patch)
treed21da298f5e8df205f31d792d684075f693f8546
parent9d1f97796dc000eedd2abd032c55639413e65c6c (diff)
downloadpaludis-fe5d06be3529fcd8a11205c6d7762a329a438f3a.tar.gz
paludis-fe5d06be3529fcd8a11205c6d7762a329a438f3a.tar.xz
Add rmdir member function to FSEntry.
-rw-r--r--paludis/util/fs_entry.cc13
-rw-r--r--paludis/util/fs_entry.hh11
2 files changed, 24 insertions, 0 deletions
diff --git a/paludis/util/fs_entry.cc b/paludis/util/fs_entry.cc
index e9141a5..913ba90 100644
--- a/paludis/util/fs_entry.cc
+++ b/paludis/util/fs_entry.cc
@@ -378,6 +378,19 @@ FSEntry::unlink()
throw FSError("unlink '" + _path + "' failed: " + ::strerror(e));
}
+bool
+FSEntry::rmdir()
+{
+ if (0 == ::rmdir(_path.c_str()))
+ return true;
+
+ int e(errno);
+ if (e == ENOENT)
+ return false;
+ else
+ throw FSError("rmdir '" + _path + "' failed: " + ::strerror(e));
+}
+
std::string
FSEntry::readlink() const
{
diff --git a/paludis/util/fs_entry.hh b/paludis/util/fs_entry.hh
index 703d64e..45e9a1c 100644
--- a/paludis/util/fs_entry.hh
+++ b/paludis/util/fs_entry.hh
@@ -255,6 +255,17 @@ namespace paludis
bool unlink();
/**
+ * Try to rmdir.
+ *
+ * \return True, if we succeeded, and false if we don't exist
+ * already.
+ *
+ * \exception FSError If an error other than us already not
+ * existing occurs.
+ */
+ bool rmdir();
+
+ /**
* Change our permissions.
*
* \exception FSError If the chown failed.