From bc7850c3c8f41d1db4fc768d995b849008aeaaf1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaakko=20Ker=C3=A4nen?= Date: Wed, 20 Jan 2016 17:32:03 +0200 Subject: [PATCH] Fixed|libcore|FS: Indexing packages with versions; LinkFile in file listing When indexing packages (.pack), remove the possible version number from the indexed name. When listing folder contents as text, show the target paths of LinkFiles. --- doomsday/sdk/libcore/src/filesys/file.cpp | 14 ++++++++++++++ doomsday/sdk/libcore/src/filesys/fileindex.cpp | 10 +++++++++- doomsday/sdk/libcore/src/filesys/packageloader.cpp | 4 +--- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/doomsday/sdk/libcore/src/filesys/file.cpp b/doomsday/sdk/libcore/src/filesys/file.cpp index 166c7d8ff1..91b357db5f 100644 --- a/doomsday/sdk/libcore/src/filesys/file.cpp +++ b/doomsday/sdk/libcore/src/filesys/file.cpp @@ -27,6 +27,7 @@ #include "de/RecordValue" #include "de/Guard" #include "de/DirectoryFeed" +#include "de/LinkFile" namespace de { @@ -378,6 +379,19 @@ String File::fileListAsText(QList files) .arg(f->size(), 9) .arg(f->status().modifiedAt.asText()) .arg(f->name()); + + // Link target. + if(LinkFile const *link = f->maybeAs()) + { + if(!link->isBroken()) + { + txt += QString(" -> %1").arg(link->target().path()); + } + else + { + txt += " (broken link)"; + } + } } return txt; } diff --git a/doomsday/sdk/libcore/src/filesys/fileindex.cpp b/doomsday/sdk/libcore/src/filesys/fileindex.cpp index 3180e04815..916304a088 100644 --- a/doomsday/sdk/libcore/src/filesys/fileindex.cpp +++ b/doomsday/sdk/libcore/src/filesys/fileindex.cpp @@ -35,7 +35,15 @@ DENG2_PIMPL(FileIndex), public ReadWriteLockable static String indexedName(File const &file) { - return file.name().lower(); + String name = file.name().lower(); + + // Ignore the package version in the indexed names. + if(name.endsWith(".pack")) + { + name = Package::split(name.fileNameWithoutExtension()).first + ".pack"; + } + + return name; } void add(File const &file) diff --git a/doomsday/sdk/libcore/src/filesys/packageloader.cpp b/doomsday/sdk/libcore/src/filesys/packageloader.cpp index fa05a777ee..05359c9126 100644 --- a/doomsday/sdk/libcore/src/filesys/packageloader.cpp +++ b/doomsday/sdk/libcore/src/filesys/packageloader.cpp @@ -75,7 +75,6 @@ DENG2_PIMPL(PackageLoader) auto idVer = Package::split(packageIdVer); String const packageId = idVer.first; - qDebug() << "looking for" << packageId; QStringList const components = packageId.split('.'); String id; @@ -94,7 +93,6 @@ DENG2_PIMPL(PackageLoader) id + ".pack", files); files.remove_if([&packageId] (File *file) { - qDebug() << "found:" << file->path(); if(shouldIgnoreFile(*file)) return true; return Package::identifierForFile(*file) != packageId; }); @@ -141,7 +139,7 @@ DENG2_PIMPL(PackageLoader) if(!findAllVariants(packageId, found)) { // None found. - return 0; + return nullptr; } // Each must have a version specified.