aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-05-07 19:15:10 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-05-07 19:15:10 +0000
commit9c74da97cff06a0f225e92aa4d42d1ce8e1439a2 (patch)
tree67536dd475b86fd8267a5820630887cb18dc3d0e
parenta6b46b02224c850bf7e2fddb11c19bc574794ad9 (diff)
downloadpaludis-9c74da97cff06a0f225e92aa4d42d1ce8e1439a2.tar.gz
paludis-9c74da97cff06a0f225e92aa4d42d1ce8e1439a2.tar.xz
BSD's realpath is silly. Fixes: ticket:217
-rw-r--r--configure.ac8
-rw-r--r--paludis/util/fs_entry.cc22
2 files changed, 30 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
index bf1f9e0..5b54d1d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -398,6 +398,14 @@ AC_CHECK_FUNCS([chflags])
AM_CONDITIONAL(HAVE_CHFLAGS, test x$ac_cv_func_chflags = xyes)
dnl }}}
+dnl {{{ check for canonicalize_file_name function
+AC_CHECK_FUNCS([canonicalize_file_name])
+AM_CONDITIONAL(HAVE_CANONICALIZE_FILE_NAME, test x$ac_cv_func_canonicalize_file_name = xyes)
+if test "x$ac_cv_func_canonicalize_file_name" = "xyes"; then
+ AC_DEFINE([HAVE_CANONICALIZE_FILE_NAME], [1], [Use canonicalize_file_name])
+fi
+dnl }}}
+
dnl {{{ check for cxxflags
if test x = x"$LET_ME_RICE"
then
diff --git a/paludis/util/fs_entry.cc b/paludis/util/fs_entry.cc
index ed592a9..4e4c1b0 100644
--- a/paludis/util/fs_entry.cc
+++ b/paludis/util/fs_entry.cc
@@ -364,11 +364,22 @@ FSEntry::realpath() const
{
Context context("When fetching realpath of '" + stringify(_path) + "':");
+#ifdef HAVE_CANONICALIZE_FILE_NAME
+ char * r(canonicalize_file_name(_path.c_str()));
+ if (! r)
+ throw FSError("Could not resolve path '" + _path + "'");
+ FSEntry result(r);
+ std::free(r);
+ return result;
+#else
char r[PATH_MAX + 1];
std::memset(r, 0, PATH_MAX + 1);
+ if (! exists())
+ throw FSError("Could not resolve path '" + _path + "'");
if (! ::realpath(_path.c_str(), r))
throw FSError("Could not resolve path '" + _path + "'");
return FSEntry(r);
+#endif
}
FSEntry
@@ -376,11 +387,22 @@ FSEntry::realpath_if_exists() const
{
Context context("When fetching realpath of '" + stringify(_path) + "', if it exists:");
+#ifdef HAVE_CANONICALIZE_FILE_NAME
+ char * r(canonicalize_file_name(_path.c_str()));
+ if (! r)
+ return *this;
+ FSEntry result(r);
+ std::free(r);
+ return result;
+#else
char r[PATH_MAX + 1];
std::memset(r, 0, PATH_MAX + 1);
+ if (! exists())
+ return *this;
if (! ::realpath(_path.c_str(), r))
return *this;
return FSEntry(r);
+#endif
}
FSEntry