23 #include "pathfinder.h" 25 #include "configuration/doomseekerconfig.h" 26 #include "pathfinder/caseinsensitivefsfileseeker.h" 27 #include "pathfinder/casesensitivefsfileseeker.h" 28 #include "pathfinder/filesearchpath.h" 29 #include "datapaths.h" 36 DClass<PathFinderResult>
39 QStringList foundFiles;
40 QStringList missingFiles;
51 PathFinderResult::~PathFinderResult()
67 return d->missingFiles;
72 return d->missingFiles;
80 QList<FileSearchPath> searchPaths;
89 d->searchPaths = gConfig.combinedWadseekPaths();
94 foreach (
const QString& path, paths)
96 d->searchPaths << path;
100 PathFinder::~PathFinder()
107 #if defined(Q_OS_WIN32) 109 << gDefaultDataPaths->workingDirectory()
110 << gDefaultDataPaths->workingDirectory() +
"/.." 114 paths <<
"/usr/bin" <<
"/usr/local/bin" <<
"/usr/share/bin" 115 <<
"/usr/games/" <<
"/usr/local/games/" 116 <<
"/usr/share/games/" << gDefaultDataPaths->workingDirectory() <<
".";
118 QStringList pathsCopy(paths);
119 foreach (
const QString &path, pathsCopy)
121 foreach (
const QString &suffix, suffixes)
131 QFileInfo fileInfo(dir);
132 if(fileInfo.isSymLink())
133 fileInfo = QFileInfo(fileInfo.symLinkTarget());
135 if(fileInfo.isBundle())
136 d->searchPaths.prepend(fileInfo.absoluteFilePath() +
"/Contents/MacOS");
139 if(fileInfo.isFile())
140 d->searchPaths.prepend(fileInfo.absoluteDir().absolutePath());
142 d->searchPaths.prepend(fileInfo.absoluteFilePath());
148 QFileInfo fileInfo(dir);
149 if(fileInfo.isSymLink())
150 fileInfo = QFileInfo(fileInfo.symLinkTarget());
152 if(fileInfo.isBundle())
153 d->searchPaths << fileInfo.absoluteFilePath() +
"/Contents/MacOS";
156 if(fileInfo.isFile())
157 d->searchPaths << fileInfo.absoluteDir().absolutePath();
159 d->searchPaths << fileInfo.absoluteFilePath();
165 if (d->searchPaths.count() == 0)
176 QString result = seeker->findFile(fileName, d->searchPaths);
184 foreach(
const QString file, files)
186 QString filePath = findFile(file);
187 if (filePath.isNull())
static QString combinePaths(QString pathFront, QString pathEnd)
Result of multiple file search operation done by PathFinder.
Performs a case-insensitive (OS independent) file searches.
QStringList & missingFiles()
Names of not found files.
void addSearchDir(const QString &dir)
Adds directory where search will be performed.
QStringList & foundFiles()
Paths to found files.
PathFinderResult findFiles(const QStringList &files) const
Performs a search for multiple files, marking them as found or missing.
PathFinder()
Constructs PathFinder where paths are read from program configuration from file (WAD) path list setti...
static QString programFilesDirectory(MachineType machineType)
QString findFile(const QString &fileName) const
Performs a search for a single file.
For case-sensitive file systems (like ext).
static PathFinder genericPathFinder(const QStringList &suffixes)
Generic PathFinder that looks in PATH and other common dirs.
void addPrioritySearchDir(const QString &dir)
For case-insensitive file systems (like NTFS).