23 #include "wadpathfinder.h" 25 #include "configuration/doomseekerconfig.h" 26 #include "pathfinder/filealias.h" 27 #include "pathfinder/pathfinder.h" 28 #include "serverapi/server.h" 43 WadFindResult::~WadFindResult()
47 const QString &WadFindResult::alias()
const 52 void WadFindResult::setAlias(
const QString &val)
57 bool WadFindResult::isAlias()
const 59 return isValid() && !d->alias.isEmpty();
62 bool WadFindResult::isValid()
const 64 return !d->path.isEmpty();
67 const QString &WadFindResult::path()
const 72 void WadFindResult::setPath(
const QString &val)
80 QList<FileAlias> aliases;
84 QStringList defaultPaths()
88 paths <<
"/usr/local/share/games/doom/" 89 <<
"/usr/share/games/doom/";
99 d->aliases = gConfig.doomseeker.wadAliases();
100 d->aliasesAllowed =
true;
101 d->pathFinder = pathFinder;
102 for (
const QString &path : d->defaultPaths())
103 d->pathFinder.addSearchDir(path);
106 WadPathFinder::~WadPathFinder()
110 QStringList WadPathFinder::aliases(
const QString &name)
const 112 if (!d->aliasesAllowed)
113 return QStringList();
120 QString path = d->pathFinder.findFile(name);
124 result.setPath(path);
128 for (
const QString &alias : aliases(name))
130 QString path = d->pathFinder.findFile(alias);
134 result.setPath(path);
135 result.setAlias(alias);
144 d->aliasesAllowed = allowed;
148 WadFindResult findWad(ServerPtr server,
const QString &wadName)
150 PathFinder pathFinder = server->wadPathFinder();
152 return wadFinder.find(wadName);
Performs a case-insensitive (OS independent) file searches.
void setAllowAliases(bool allowed)
Can disable WAD aliasing for contexts where only specific WADs should be found.
Wrapper for PathFinder that specializes in findings WADs.
static QStringList aliases(const QList< FileAlias > &candidates, const QString &name)