From d700acfbd653e179b8de680981f86e7e88cab517 Mon Sep 17 00:00:00 2001 From: codereader Date: Sat, 15 Jul 2017 21:08:53 +0200 Subject: [PATCH] Fix #4570: display folders in entity selector and sound chooser are cluttered with PK4 top level nodes when DR is just pointed just to the TDM root path. --- plugins/archivezip/ZipArchive.cpp | 14 +++++++++----- plugins/archivezip/ZipArchive.h | 3 ++- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/plugins/archivezip/ZipArchive.cpp b/plugins/archivezip/ZipArchive.cpp index fd5d04f322..52f141b802 100644 --- a/plugins/archivezip/ZipArchive.cpp +++ b/plugins/archivezip/ZipArchive.cpp @@ -5,6 +5,7 @@ #include "pkzip.h" #include "zlibstream.h" +#include "os/fs.h" #include "os/path.h" #include "DeflatedArchiveFile.h" @@ -12,11 +13,14 @@ ZipArchive::ZipArchive(const std::string& name) : m_name(name), + _containingFolder(os::standardPathWithSlash(fs::path(name).remove_filename())), m_istream(name) { - if (!m_istream.failed()) { - if (!read_pkzip()) { - rError() << "ERROR: invalid zip-file " << name.c_str() << '\n'; + if (!m_istream.failed()) + { + if (!read_pkzip()) + { + rError() << "ERROR: invalid zip-file " << name << std::endl; } } } @@ -99,14 +103,14 @@ ArchiveTextFilePtr ZipArchive::openTextFile(const std::string& name) case ZipRecord::eStored: return ArchiveTextFilePtr(new StoredArchiveTextFile(name, m_name, - m_name, + _containingFolder, m_istream.tell(), file->m_stream_size)); case ZipRecord::eDeflated: return ArchiveTextFilePtr(new DeflatedArchiveTextFile(name, m_name, - m_name, + _containingFolder, m_istream.tell(), file->m_stream_size)); } diff --git a/plugins/archivezip/ZipArchive.h b/plugins/archivezip/ZipArchive.h index df37b79ac1..22f2469794 100644 --- a/plugins/archivezip/ZipArchive.h +++ b/plugins/archivezip/ZipArchive.h @@ -34,7 +34,8 @@ class ZipArchive : public Archive { ZipFileSystem m_filesystem; - std::string m_name; + std::string m_name; // the full path to this Zip + std::string _containingFolder; // the folder this Zip is located in FileInputStream m_istream; std::mutex _streamLock;