Skip to content

Commit dd38276

Browse files
committed
expect input, media and gamelist folder to be absolute for RA
1 parent 856d07c commit dd38276

6 files changed

Lines changed: 42 additions & 20 deletions

File tree

docs/FRONTENDS.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,9 +311,11 @@ specific to your setup you can define in `~/.skyscraper/peas_local.json`. This
311311
file uses the same format as the `peas.json`.
312312

313313
You can optionally use the `-e` parameter with `"<CORE_PATH>;<CORE_NAME>"` to
314-
set a default core path/name for the playlist. Or set it in `config.ini` like:
314+
set a default core path/name for the playlist. Or set
315+
[`raExtra`](CONFIGINI.md#raextra) it in `config.ini` like:
315316

316317
```ini
318+
; also allowed in [<platform>]
317319
[retroarch]
318320
raExtra="<CORE_PATH>;<CORE_NAME>"
319321
```

docs/PATHHANDLING.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ how the absolute path is calculated when a you provide a relative path.
1212

1313
Do not get confused by the lenghty flow diagram below. It covers game list folder,
1414
input folder and media folder handling. You wiil notice that input folder and
15-
media folder are processed in the same manner.
15+
media folder are almost processed in the same manner.
16+
17+
If you use generate output with Skyscraper for RetroArch as frontend you can
18+
stop reading as Skyscraper expects any of the three parameters input, gamelist
19+
and media folder to be absolute.
1620

1721
<figure markdown style="width:100%">
1822
<img style="width:100%" src="../resources/path_handling_flow.svg"/>

src/retroarch.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,7 @@ QString RetroArch::getWheelsFolder() {
299299
return config->mediaFolder % "/Named_Logos";
300300
}
301301

302-
// PENDING: This media type does exist yet...
303-
302+
// PENDING: This media type is supported by RA but not yet by Skyscraper
304303
/*
305304
QString RetroArch::getTitleScreenshotsFolder() {
306305
return config->mediaFolder % "/Named_Titles";

src/settings.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,10 @@ void RuntimeCfg::applyConfigIni(CfgType type, QSettings *settings,
247247
type == CfgType::FRONTEND /* #68 */)
248248
? PathTools::concatPath(v, config->platform)
249249
: v;
250-
config->gameListFolder = toAbsolutePath(false, v);
250+
// do not elaborate abs path for retroarch
251+
config->gameListFolder = config->frontend == "retroarch"
252+
? config->gameListFolder
253+
: toAbsolutePath(false, v);
251254
gameListFolderSet = true;
252255
continue;
253256
}
@@ -678,7 +681,10 @@ void RuntimeCfg::applyCli(bool &inputFolderSet, bool &gameListFolderSet,
678681
config->inputFolderNotMain = true;
679682
}
680683
if (parser->isSet("g")) {
681-
config->gameListFolder = toAbsolutePath(true, parser->value("g"));
684+
// do not elaborate abs path for retroarch
685+
config->gameListFolder = config->frontend == "retroarch"
686+
? config->gameListFolder
687+
: toAbsolutePath(true, parser->value("g"));
682688
gameListFolderSet = true;
683689
}
684690
if (parser->isSet("o")) {

src/skyscraper.cpp

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1030,6 +1030,14 @@ void Skyscraper::loadConfig(const QCommandLineParser &parser) {
10301030
if (config.frontend == "retroarch") {
10311031
if (!inputFolderSet) {
10321032
config.inputFolder = frontend->getInputFolder();
1033+
} else {
1034+
validateAbsolutePath("inputFolder", config.inputFolder);
1035+
}
1036+
if (gameListFolderSet) {
1037+
validateAbsolutePath("gameListFolder", config.gameListFolder);
1038+
}
1039+
if (mediaFolderSet) {
1040+
validateAbsolutePath("mediaFolder", config.mediaFolder);
10331041
}
10341042
// do call these ignoring gameListFolderSet and mediaFolderSet
10351043
// as they will adjust the path to retroarch specs
@@ -1067,7 +1075,6 @@ void Skyscraper::loadConfig(const QCommandLineParser &parser) {
10671075
PathTools::expandHomePath(config.inputFolder);
10681076
PathTools::expandHomePath(config.mediaFolder);
10691077

1070-
const QFileInfo inputDirFileInfo = QFileInfo(config.inputFolder);
10711078
if (config.frontend == "pegasus" || config.frontend == "batocera") {
10721079
// defaults are always absolute, thus input- and mediafolder will be
10731080
// unchanged by these calls.
@@ -1083,10 +1090,10 @@ void Skyscraper::loadConfig(const QCommandLineParser &parser) {
10831090
config.mediaFolder = PathTools::makeAbsolutePath(config.gameListFolder,
10841091
config.mediaFolder);
10851092
} else if (config.frontend == "retroarch") {
1086-
checkForAbsoluteInputFolder(inputDirFileInfo);
1087-
// media and gamelist folder already in proper format (see above)
1093+
; // pass through, checks made above
10881094
} else {
1089-
checkForAbsoluteInputFolder(inputDirFileInfo);
1095+
validateAbsolutePath("inputFolder", config.inputFolder);
1096+
const QFileInfo inputDirFileInfo = QFileInfo(config.inputFolder);
10901097
QString last = config.inputFolder.split("/").last();
10911098
config.gameListFolder = removeSurplusPlatformPath(
10921099
config.platform, last, config.gameListFolder);
@@ -1278,16 +1285,20 @@ void Skyscraper::loadConfig(const QCommandLineParser &parser) {
12781285
}
12791286
}
12801287

1281-
void Skyscraper::checkForAbsoluteInputFolder(
1282-
const QFileInfo &inputDirFileInfo) {
1283-
if (inputDirFileInfo.isRelative()) {
1284-
ncprintf("\033[1;31mBummer!\033[0m The parameter 'inputFolder' is "
1285-
"provided as relative path which is not valid for this "
1286-
"frontend. Provide the input folder as absolute path to "
1287-
"remediate. Now quitting...\n");
1288+
void Skyscraper::validateAbsolutePath(const QString &param,
1289+
const QString &path) {
1290+
if (QFileInfo(path).isRelative()) {
1291+
ncprintf("\033[1;31mBummer!\033[0m The value of '%s' is "
1292+
"provided as relative path which is not valid for the "
1293+
"frontend '%s'. Provide '%s' as absolute path to "
1294+
"remediate. Now quitting...\n",
1295+
param.toStdString().c_str(),
1296+
config.frontend.toStdString().c_str(),
1297+
param.toStdString().c_str());
12881298
emit die(
1289-
1, "invalid frontend and input folder combination",
1290-
QString("Input folder may not be a relative path for frontend '%1'")
1299+
1, "invalid frontend and path combination",
1300+
QString("path of '%1' may not be a relative path for frontend '%2'")
1301+
.arg(param)
12911302
.arg(config.frontend));
12921303
}
12931304
}

src/skyscraper.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ private slots:
106106
const std::string mediaSubFolderStdStr(QString &in);
107107

108108
QList<QString> readFileListFrom(const QString &filename);
109-
void checkForAbsoluteInputFolder(const QFileInfo &inputDirFileInfo);
109+
void validateAbsolutePath(const QString &param, const QString &path);
110110

111111
QSharedPointer<AbstractFrontend> frontend;
112112
QSharedPointer<Cache> cache;

0 commit comments

Comments
 (0)