From 83c726a34f325ae5be0d5b61b66a97cb41f6973e Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 21 Oct 2013 10:26:53 +0200 Subject: GetBaseUTF8 --- src/archive/Bzip2ArchivePlugin.cxx | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/archive') diff --git a/src/archive/Bzip2ArchivePlugin.cxx b/src/archive/Bzip2ArchivePlugin.cxx index ec44ddd23..be8e66fc7 100644 --- a/src/archive/Bzip2ArchivePlugin.cxx +++ b/src/archive/Bzip2ArchivePlugin.cxx @@ -32,12 +32,13 @@ #include "util/RefCount.hxx" #include "util/Error.hxx" #include "util/Domain.hxx" +#include "fs/Traits.hxx" + +#include #include #include #include -#include -#include #ifdef HAVE_OLDER_BZIP2 #define BZ2_bzDecompressInit bzDecompressInit @@ -48,17 +49,17 @@ class Bzip2ArchiveFile final : public ArchiveFile { public: RefCount ref; - char *const name; + std::string name; struct input_stream *const istream; Bzip2ArchiveFile(const char *path, input_stream *_is) :ArchiveFile(bz2_archive_plugin), - name(g_path_get_basename(path)), + name(PathTraits::GetBaseUTF8(path)), istream(_is) { // remove .bz2 suffix - size_t len = strlen(name); + const size_t len = name.length(); if (len > 4) - name[len - 4] = 0; + name.erase(len - 4); } ~Bzip2ArchiveFile() { @@ -73,7 +74,6 @@ public: if (!ref.Decrement()) return; - g_free(name); delete this; } @@ -82,7 +82,7 @@ public: } virtual void Visit(ArchiveVisitor &visitor) override { - visitor.VisitArchiveEntry(name); + visitor.VisitArchiveEntry(name.c_str()); } virtual input_stream *OpenStream(const char *path, -- cgit v1.2.3