Skip to content

Commit

Permalink
Fixed|libcore|FS: Indexing packages with versions; LinkFile in file l…
Browse files Browse the repository at this point in the history
…isting

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.
  • Loading branch information
skyjake committed Jan 20, 2016
1 parent 5d89daa commit bc7850c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
14 changes: 14 additions & 0 deletions doomsday/sdk/libcore/src/filesys/file.cpp
Expand Up @@ -27,6 +27,7 @@
#include "de/RecordValue"
#include "de/Guard"
#include "de/DirectoryFeed"
#include "de/LinkFile"

namespace de {

Expand Down Expand Up @@ -378,6 +379,19 @@ String File::fileListAsText(QList<File const *> files)
.arg(f->size(), 9)
.arg(f->status().modifiedAt.asText())
.arg(f->name());

// Link target.
if(LinkFile const *link = f->maybeAs<LinkFile>())
{
if(!link->isBroken())
{
txt += QString(" -> %1").arg(link->target().path());
}
else
{
txt += " (broken link)";
}
}
}
return txt;
}
Expand Down
10 changes: 9 additions & 1 deletion doomsday/sdk/libcore/src/filesys/fileindex.cpp
Expand Up @@ -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)
Expand Down
4 changes: 1 addition & 3 deletions doomsday/sdk/libcore/src/filesys/packageloader.cpp
Expand Up @@ -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;
Expand All @@ -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;
});
Expand Down Expand Up @@ -141,7 +139,7 @@ DENG2_PIMPL(PackageLoader)
if(!findAllVariants(packageId, found))
{
// None found.
return 0;
return nullptr;
}

// Each must have a version specified.
Expand Down

0 comments on commit bc7850c

Please sign in to comment.