changeset 478:585427943384

Irccd: use boost::filesystem (fs::isAbsolute), #594
author David Demelier <markand@malikania.fr>
date Tue, 14 Feb 2017 13:07:47 +0100
parents bf201d09ee6a
children 298cae7487dc
files libcommon/irccd/fs.cpp libcommon/irccd/fs.hpp libcommon/irccd/path.cpp
diffstat 3 files changed, 2 insertions(+), 44 deletions(-) [+]
line wrap: on
line diff
--- a/libcommon/irccd/fs.cpp	Tue Feb 14 13:05:42 2017 +0100
+++ b/libcommon/irccd/fs.cpp	Tue Feb 14 13:07:47 2017 +0100
@@ -213,32 +213,6 @@
 }
 
 /*
- * isAbsolute.
- * ------------------------------------------------------------------
- */
-bool isAbsolute(const std::string &path) noexcept
-{
-#if defined(_WIN32)
-    return !isRelative(path);
-#else
-    return path.size() > 0 && path[0] == '/';
-#endif
-}
-
-/*
- * isRelative.
- * ------------------------------------------------------------------
- */
-bool isRelative(const std::string &path) noexcept
-{
-#if defined(_WIN32)
-    return PathIsRelativeA(path.c_str()) == 1;
-#else
-    return !isAbsolute(path);
-#endif
-}
-
-/*
  * isReadable.
  * ------------------------------------------------------------------
  */
--- a/libcommon/irccd/fs.hpp	Tue Feb 14 13:05:42 2017 +0100
+++ b/libcommon/irccd/fs.hpp	Tue Feb 14 13:07:47 2017 +0100
@@ -169,22 +169,6 @@
 #endif // !HAVE_STAT
 
 /**
- * Check if the path is absolute.
- *
- * \param path the path
- * \return true if the path is absolute
- */
-IRCCD_EXPORT bool isAbsolute(const std::string &path) noexcept;
-
-/**
- * Check if the path is relative.
- *
- * \param path the path
- * \return true if the path is absolute
- */
-IRCCD_EXPORT bool isRelative(const std::string &path) noexcept;
-
-/**
  * Check if the file is readable.
  *
  * \param path the path
--- a/libcommon/irccd/path.cpp	Tue Feb 14 13:05:42 2017 +0100
+++ b/libcommon/irccd/path.cpp	Tue Feb 14 13:07:47 2017 +0100
@@ -394,9 +394,9 @@
      * In the worst case use current working directory.
      */
     if (base.empty()) {
-        if (fs::isAbsolute(argv0))
+        if (boost::filesystem::path(argv0).is_absolute()) {
             base = argv0;
-        else {
+        } else {
             std::string name = fs::baseName(argv0);
 
             for (const auto &dir : util::split(sys::env("PATH"), std::string(1, Separator))) {