@@ -291,39 +291,43 @@ int FileManager::checkFileInfo(const QString& file, bool lookGameDir) {
291291 return status;
292292}
293293
294- bool FileManager::linkGameDir (const QString& levelDir, const QString& gameDir) {
295- bool status = false ;
294+ QString FileManager::getExtraPath (const QString& levelDir) {
296295 const QString levelPath = QString (" %1%2" )
297296 .arg (m_levelDir.absolutePath (), levelDir);
298- const QString gamePath = QString (" %1/%2" )
299- .arg (m_gameDir.absolutePath (), gameDir);
300-
301297 StaticTrees staticTrees;
302298 QDir dir (levelPath);
303- GameFileTree test (dir);
304- test .printTree (1 );
299+ GameFileTree tree (dir);
300+ tree .printTree (1 );
305301 QString extraPath;
306302
307- for (const GameFileTree* tree : staticTrees.data ) {
308- extraPath = test .matchesFromAnyNode (tree );
303+ for (const GameFileTree* stree : staticTrees.data ) {
304+ extraPath = tree .matchesFromAnyNode (stree );
309305 if ((extraPath != QString (" \0 " )) && (!extraPath.isEmpty ())) {
310306 QTextStream (stdout)
311307 << " game tree matches: " << extraPath << Qt::endl;
312308 break ;
313309 }
314310 }
311+ return levelPath + extraPath;
312+ }
313+
314+ bool FileManager::linkGameDir (const QString& levelDir, const QString& gameDir) {
315+ bool status = false ;
316+ const QString gamePath = QString (" %1/%2" )
317+ .arg (m_gameDir.absolutePath (), gameDir);
315318
319+ const QString levelPath = getExtraPath (levelDir);
316320 qDebug () << " levelPath: " << levelPath;
317321 qDebug () << " gamePath: " << gamePath;
318322
319- if (QFile::link (levelPath + extraPath , gamePath) == true ) {
323+ if (QFile::link (levelPath, gamePath) == true ) {
320324 qDebug () << " Symbolic link created successfully." ;
321325 status = true ;
322326 } else {
323327 QFileInfo fileInfo (gamePath);
324328 if (fileInfo.isSymLink () == true ) {
325329 (void )QFile::remove (gamePath);
326- if (QFile::link (levelPath + extraPath , gamePath) == true ) {
330+ if (QFile::link (levelPath, gamePath) == true ) {
327331 qDebug () << " Symbolic link created successfully." ;
328332 status = true ;
329333 } else {
0 commit comments