23 #include "pathfinder.h"
25 #include "configuration/doomseekerconfig.h"
26 #include "datapaths.h"
27 #include "fileseeker.h"
29 #include "pathfinder/filesearchpath.h"
30 #include "strings.hpp"
31 #include "templatedpathresolver.h"
34 #include <QCoreApplication>
37 #include <QScopedPointer>
38 #include <QSharedPointer>
40 DClass<PathFinderResult>
43 QStringList foundFiles;
44 QStringList missingFiles;
55 PathFinderResult::~PathFinderResult()
71 return d->missingFiles;
76 return d->missingFiles;
84 QSharedPointer <QList<FileSearchPath> > searchPaths;
86 QString resolveDir(
const QString &dir)
89 if (fileInfo.isSymLink())
90 fileInfo = QFileInfo(fileInfo.symLinkTarget());
92 if (fileInfo.isBundle())
93 return fileInfo.absoluteFilePath() +
"/Contents/MacOS";
96 if (fileInfo.isFile())
97 return fileInfo.absoluteDir().absolutePath();
99 return fileInfo.absoluteFilePath();
110 d->searchPaths.reset(
new QList<FileSearchPath>());
112 d->searchPaths->append(
113 FileSearchPath::resolveTemplated(resolver,
114 gConfig.combinedWadseekPaths()));
120 d->searchPaths.reset(
new QList<FileSearchPath>());
121 for (
const QString &path : paths)
122 d->searchPaths->append(path);
126 PathFinder::~PathFinder()
133 #if defined(Q_OS_WIN32)
135 << QCoreApplication::applicationDirPath()
136 << QDir(QCoreApplication::applicationDirPath()).filePath(
"..")
140 paths <<
"/usr/bin" <<
"/usr/local/bin" <<
"/usr/share/bin"
141 <<
"/usr/games/" <<
"/usr/local/games/"
142 <<
"/usr/share/games/" << QCoreApplication::applicationDirPath() <<
".";
144 QStringList pathsCopy(paths);
145 for (
const QString &path : pathsCopy)
147 for (
const QString &suffix : suffixes)
157 d->searchPaths->prepend(d->resolveDir(dir));
163 d->searchPaths->append(d->resolveDir(dir));
169 if (d->searchPaths->count() == 0)
171 QScopedPointer<FileSeeker> seeker(FileSeeker::createSeeker(d->searchPaths));
172 QString result = seeker->findFile(fileName);
179 for (
const QString &file : files)
182 if (filePath.isNull())