From abfbd55305587306730d5419b8a3b09e6a43abcb Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 17 Oct 2013 21:59:35 +0200 Subject: fs/Path: rename to AllocatedPath The new class Path only holds a string pointer without being responsible for allocation/deallocation. The FileSystem.hxx library accepts Path arguments instead of AllocatedPath, to avoid forcing callers to allocate another string object. --- src/fs/Path.cxx | 64 +-------------------------------------------------------- 1 file changed, 1 insertion(+), 63 deletions(-) (limited to 'src/fs/Path.cxx') diff --git a/src/fs/Path.cxx b/src/fs/Path.cxx index ecdf73e49..0ff0591fb 100644 --- a/src/fs/Path.cxx +++ b/src/fs/Path.cxx @@ -19,57 +19,12 @@ #include "config.h" #include "Path.hxx" -#include "Domain.hxx" #include "Charset.hxx" -#include "util/Error.hxx" -#include "Compiler.h" - -#include - -#include -#include - -inline Path::Path(Donate, pointer _value) - :value(_value) { - g_free(_value); -} - -/* no inlining, please */ -Path::~Path() {} - -Path -Path::Build(const_pointer a, const_pointer b) -{ - return Path(Donate(), g_build_filename(a, b, nullptr)); -} - -Path Path::FromUTF8(const char *path_utf8) -{ - return Path(Donate(), ::PathFromUTF8(path_utf8)); -} - -Path -Path::FromUTF8(const char *path_utf8, Error &error) -{ - Path path = FromUTF8(path_utf8); - if (path.IsNull()) - error.Format(path_domain, - "Failed to convert to file system charset: %s", - path_utf8); - - return path; -} - -Path -Path::GetDirectoryName() const -{ - return Path(Donate(), g_path_get_dirname(value.c_str())); -} std::string Path::ToUTF8() const { - return ::PathToUTF8(value.c_str()); + return ::PathToUTF8(c_str()); } const char * @@ -93,20 +48,3 @@ Path::RelativeFS(const char *other_fs) const return other_fs; } - -void -Path::ChopSeparators() -{ - size_t l = length(); - const char *p = data(); - - while (l >= 2 && PathTraits::IsSeparatorFS(p[l - 1])) { - --l; - -#if GCC_CHECK_VERSION(4,7) && !defined(__clang__) - value.pop_back(); -#else - value.erase(value.end() - 1, value.end()); -#endif - } -} -- cgit v1.2.3