2828#include " attractmode.h"
2929#include " batocera.h"
3030#include " cli.h"
31+ #include " compositor.h"
3132#include " config.h"
3233#include " emulationstation.h"
3334#include " esde.h"
@@ -396,6 +397,14 @@ void Skyscraper::run() {
396397 }
397398 }
398399 printf (" \n " );
400+
401+ if (!Compositor::preCheckArtworkXml (config.artworkXml )) {
402+ printf (" Parsing artwork XML from '%s', failed, see above."
403+ " Check the file for errors. Now exiting...\n " ,
404+ config.artworkConfig .toStdString ().c_str ());
405+ exit (1 );
406+ }
407+
399408 if (!doCacheScraping) {
400409 printf (" Starting scraping run on \033 [1;32m%d\033 [0m files using "
401410 " \033 [1;32m%d\033 [0m threads.\n Sit back, relax and let me do "
@@ -445,7 +454,7 @@ void Skyscraper::prepareFileQueue() {
445454 QDir inputDir (config.inputFolder , getPlatformFileExtensions (), QDir::Name,
446455 filter);
447456 if (!inputDir.exists ()) {
448- printf (" Input folder '\033 [1;32m %s\033 [0m' doesn't exist or can't be "
457+ printf (" Input folder '\033 [1;31m %s\033 [0m' doesn't exist or can't be "
449458 " accessed by current user. Please check path and permissions.\n " ,
450459 inputDir.absolutePath ().toStdString ().c_str ());
451460 exit (1 );
@@ -588,20 +597,17 @@ void Skyscraper::setFolder(const bool doCacheScraping, QString &outFolder,
588597
589598void Skyscraper::checkForFolder (QDir &folder, bool create) {
590599 if (!folder.exists ()) {
591- printf (" Folder '%s' doesn't exist" ,
592- folder.absolutePath ().toStdString ().c_str ());
593600 if (create) {
594- printf (" , trying to create it... " );
595- fflush (stdout);
596- if (folder.mkpath (folder.absolutePath ())) {
597- printf (" \033 [1;32mSuccess!\033 [0m\n " );
598- } else {
599- printf (" \033 [1;32mFailed!\033 [0m Please check path and "
600- " permissions, now exiting...\n " );
601+ if (!folder.mkpath (folder.absolutePath ())) {
602+ printf (
603+ " Create folder '\033 [1;31m%s\033 [0m' failed! Please "
604+ " check path and filesystem permissions, now exiting...\n " ,
605+ folder.absolutePath ().toStdString ().c_str ());
601606 exit (1 );
602607 }
603608 } else {
604- printf (" , can't continue...\n " );
609+ printf (" Folder '%s' doesn't exist, can't continue...\n " ,
610+ folder.absolutePath ().toStdString ().c_str ());
605611 exit (1 );
606612 }
607613 }
@@ -772,6 +778,18 @@ void Skyscraper::checkThreads() {
772778 printf (" \n\n " );
773779 }
774780
781+ if (doCacheScraping) {
782+ QStringList mediaDirs = {
783+ config.coversFolder , config.screenshotsFolder ,
784+ config.wheelsFolder , config.marqueesFolder ,
785+ config.texturesFolder , config.videosFolder ,
786+ config.manualsFolder , config.fanartsFolder };
787+ for (const auto &f : mediaDirs) {
788+ QDir dir (f);
789+ dir.rmdir (f);
790+ }
791+ }
792+
775793 // All done, now clean up and exit to terminal
776794 emit finished ();
777795}
@@ -936,7 +954,7 @@ void Skyscraper::loadConfig(const QCommandLineParser &parser) {
936954 }
937955 }
938956
939- // defaults are always absolute, thus input and mediafolder will be
957+ // defaults are always absolute, thus input- and mediafolder will be
940958 // unchanged by these calls
941959 if (config.frontend == " pegasus" ) {
942960 config.inputFolder =
@@ -1016,10 +1034,7 @@ void Skyscraper::loadConfig(const QCommandLineParser &parser) {
10161034 }
10171035 if (requestedFileInfo.exists ()) {
10181036 QString romPath = requestedFileInfo.absoluteFilePath ();
1019- if (config.frontend == " emulationstation" ||
1020- config.frontend == " esde" ) {
1021- romPath = normalizePath (requestedFileInfo);
1022- }
1037+ romPath = normalizePath (requestedFileInfo);
10231038 if (!romPath.isEmpty ()) {
10241039 cliFiles.append (romPath);
10251040 // Always set refresh and unattend true if user has supplied
@@ -1031,12 +1046,12 @@ void Skyscraper::loadConfig(const QCommandLineParser &parser) {
10311046 continue ;
10321047 }
10331048 }
1034- printf (" Filename: '\033 [1;32m %s\033 [0m' requested either on "
1035- " command line or with '--includefrom' neither found in platform "
1036- " folder '%s' nor in current directory !\n\n Please verify the "
1037- " filename and try again...\n " ,
1038- requestedFile .toStdString ().c_str (),
1039- config.platform .toStdString ().c_str ());
1049+ printf (" Filename: '\033 [1;33m %s\033 [0m' requested either on command "
1050+ " line or with '--includefrom' not found in(side) the input "
1051+ " directory ' \033 [1;33m%s \033 [0m' !\n\n Please verify the filename "
1052+ " and try again...\n " ,
1053+ requestedFileInfo. fileName () .toStdString ().c_str (),
1054+ config.inputFolder .toStdString ().c_str ());
10401055 exit (1 );
10411056 }
10421057
@@ -1116,8 +1131,10 @@ QString Skyscraper::normalizePath(QFileInfo fileInfo) {
11161131 // normalize paths for single romfiles provided at the CLI.
11171132 // format will be: config.inputFolder + relative-path-of-romfile
11181133 QString canonicalRomPath = fileInfo.canonicalFilePath ();
1134+
11191135 // for Windows
11201136 QString cleanRomPath = QDir::cleanPath (canonicalRomPath);
1137+
11211138 QListIterator<QString> iter (cleanRomPath.split (" /" ));
11221139 iter.toBack ();
11231140 QString relativeRomPath;
0 commit comments