From 6a8cd5983d9d340b70b7ca755ee78c2a998b5bff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaakko=20Ker=C3=A4nen?= Date: Thu, 3 Jul 2014 08:58:50 +0300 Subject: [PATCH] libcore|PackageFeed: Links to loaded packages use the package identifier Don't link with the full name containing an extension. It's better to be agnostic of the actual format that is implied by the extension. --- doomsday/libcore/include/de/filesys/linkfile.h | 11 ++++++++++- doomsday/libcore/src/filesys/linkfile.cpp | 7 +++++-- doomsday/libcore/src/filesys/packagefeed.cpp | 4 ++-- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/doomsday/libcore/include/de/filesys/linkfile.h b/doomsday/libcore/include/de/filesys/linkfile.h index 73efd71a10..67fe05c1bb 100644 --- a/doomsday/libcore/include/de/filesys/linkfile.h +++ b/doomsday/libcore/include/de/filesys/linkfile.h @@ -80,7 +80,16 @@ class LinkFile : public File Node const *tryGetChild(String const &name) const; public: - static LinkFile *newLinkToFile(File const &file); + /** + * Creates a new link to an existing file. + * + * @param file Target file. + * @param linkName Name of the created link file. If empty, the target file's + * name is used as the link's name. + * + * @return New LinkFile instance. Caller gets ownership. + */ + static LinkFile *newLinkToFile(File const &file, String linkName = ""); private: DENG2_PRIVATE(d) diff --git a/doomsday/libcore/src/filesys/linkfile.cpp b/doomsday/libcore/src/filesys/linkfile.cpp index 23dd374c9a..c9d20b6a87 100644 --- a/doomsday/libcore/src/filesys/linkfile.cpp +++ b/doomsday/libcore/src/filesys/linkfile.cpp @@ -143,9 +143,12 @@ filesys::Node const *LinkFile::tryGetChild(String const &name) const return 0; } -LinkFile *LinkFile::newLinkToFile(File const &file) +LinkFile *LinkFile::newLinkToFile(File const &file, String linkName) { - LinkFile *link = new LinkFile(file.name()); + // Fall back to using the target's name. + if(linkName.isEmpty()) linkName = file.name(); + + LinkFile *link = new LinkFile(linkName); link->setTarget(file); link->setStatus(file.status()); return link; diff --git a/doomsday/libcore/src/filesys/packagefeed.cpp b/doomsday/libcore/src/filesys/packagefeed.cpp index 409cead94e..8f5eca9326 100644 --- a/doomsday/libcore/src/filesys/packagefeed.cpp +++ b/doomsday/libcore/src/filesys/packagefeed.cpp @@ -54,10 +54,10 @@ void PackageFeed::populate(Folder &folder) { Package *pkg = i.value(); - if(folder.has(pkg->file().name())) continue; // Already there. + if(folder.has(i.key())) continue; // Already there. // Create a link to the loaded package's file. - LinkFile &link = folder.add(LinkFile::newLinkToFile(pkg->file())); + LinkFile &link = folder.add(LinkFile::newLinkToFile(pkg->file(), i.key())); // We will decide on pruning this. link.setOriginFeed(this);