Skip to content

Commit

Permalink
libcore|PackageFeed: Links to loaded packages use the package identifier
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
skyjake committed Jul 3, 2014
1 parent 30bc553 commit 6a8cd59
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
11 changes: 10 additions & 1 deletion doomsday/libcore/include/de/filesys/linkfile.h
Expand Up @@ -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)
Expand Down
7 changes: 5 additions & 2 deletions doomsday/libcore/src/filesys/linkfile.cpp
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions doomsday/libcore/src/filesys/packagefeed.cpp
Expand Up @@ -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);
Expand Down

0 comments on commit 6a8cd59

Please sign in to comment.