Skip to content

Commit 94a4199

Browse files
committed
Changes for relative path handling of configuration options:
- Path functions added to config.cpp - Pegasus frontend refactored - Enhanced Unit-Tests - Documentation PATHHANDLING.md - Minor (unrelated to rel path) fixes for edgecases
1 parent 232c257 commit 94a4199

44 files changed

Lines changed: 1316 additions & 309 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ compile_commands.json
5555

5656
moc_*
5757
*.tmp
58+
*.bkp
5859
*.bk
5960
.qmake*
6061
Skyscraper
@@ -64,6 +65,7 @@ packages
6465
target
6566
build
6667
peas_local.json
68+
platforms_idmap_local.csv
6769

6870
# macOS
6971
.DS_Store

config.ini.example

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,17 @@
2222
; Also remember to uncomment or create the sections they belong to such as '[snes]'.
2323

2424
[main]
25-
;inputFolder="/home/pi/RetroPie/roms"
25+
;gameListFolder="/home/pi/RetroPie/roms"
26+
# next two are relative to 'gameListFolder'
27+
;inputFolder="."
28+
;mediaFolder="./media"
2629
;excludePattern="*[BIOS]*"
2730
;includePattern="Super*"
28-
;excludeFrom="/home/pi/.skyscraper/excludes.txt"
29-
;includeFrom="/home/pi/.skyscraper/includes.txt"
30-
;gameListFolder="/home/pi/RetroPie/roms"
31+
# relative to this config.ini path, also for other path parameters
32+
;excludeFrom="./excludes.txt"
33+
;includeFrom="./includes.txt"
3134
;gameListBackup="false"
32-
;mediaFolder="/home/pi/RetroPie/roms"
33-
;cacheFolder="/home/pi/.skyscraper/cache"
35+
;cacheFolder="./cache"
3436
;cacheResize="false"
3537
;nameTemplate="%t [%f], %P player(s)"
3638
;jpgQuality="95"
@@ -39,7 +41,7 @@
3941
;cacheWheels="true"
4042
;cacheMarquees="true"
4143
;cacheTextures="true"
42-
;importFolder="/home/pi/.skyscraper/import"
44+
;importFolder="./import"
4345
;unpack="false"
4446
;frontend="emulationstation"
4547
;emulator=""
@@ -73,6 +75,7 @@
7375
;hints="false"
7476
;subdirs="true"
7577
;spaceCheck="true"
78+
# only absolute path allowed
7679
;scummIni="/full/path/to/scummvm.ini"
7780
;tidyDesc="true"
7881
;onlyMissing="false"

docs/CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ humans](https://keepachangelog.com).
55

66
### Version 3.17.0 (2025-TBA)
77

8+
- Changed: Handling of relative path in configuration options adapted to enable
9+
that gamelist, ROM folder and media folder can be moved easier around or can
10+
be moved to other devices. Also, the config INI file can be provided with a
11+
relative path, as all other path options. See details [here](PATHHANDLING.md).
12+
Thanks to @cameronhimself for nudging me.
813
- Added: Artwork finetuning, added option to [control aspect ratio when
914
scaling images](ARTWORK.md#aspect-attribute-o_1). Thanks to
1015
@joyrider3774 for the suggestion.
@@ -32,7 +37,7 @@ humans](https://keepachangelog.com).
3237
RetroPie-Setup first before updating Skyscraper.
3338
- Added: Documentation on scraper modules supplied with [scraper
3439
capabilities](SCRAPINGMODULES.md#capabilities-of-scrapers).
35-
- Added: Documentation on options for --query parameter per scraper modules. See
40+
- Added: Documentation on options for `--query` parameter per scraper modules. See
3641
[here](SCRAPINGMODULES.md#recognized-keywords-in-query).
3742
- Added: IGDB scraper now supports Screenshot and Cover scraping, plus it
3843
allows querying with game ID `--query="id=..."`.

docs/CONFIGINI.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Settings in the `[main]` section will always be set regardless of selected platf
1818

1919
`<SCRAPER>` can be any of the supported scraping modules (check list with `--help` under the `-s` option), in which case the settings will only be applied while scraping with that particular scraping module.
2020

21-
Each section can have overlapping parameters. In case where a certain option exists in several sections they are prioritized as scraping module first, then frontend, then platform and lastly main. Any commandline option which relates to an configuration setting in `config.ini` has highest precedence, regardless of the other four levels respective sections.
21+
Each section can have overlapping parameters. In case where a certain option exists in several sections they are prioritized as scraping module first, then frontend, then platform and lastly main. Any commandline (CLI) option which relates to an configuration setting in `config.ini` has highest precedence, regardless of the other four levels respective sections.
2222

2323
You can find an example config file at `/home/<USER>/.skyscraper/config.ini.example`. This file contains all available options. Just copy the file to `config.ini` and uncomment and edit the ones you wish to use by removing the `#` or `;` in front of the variables. Remember to also uncomment the section the option relates to such as `[main]` or `[amiga]`.
2424

@@ -812,7 +812,7 @@ Allowed in sections: `[main]`, `[<PLATFORM>]`, `[<FRONTEND>]`
812812

813813
#### relativePaths
814814

815-
Enabling this forces the rom and any media paths inside the game list to be relative to the rom input folder. Currently only relevant when generating an EmulationStation, a Retrobat or a Pegasus game list (see also [frontend](#frontend) option).
815+
Enabling this forces the rom and any media paths inside the game list to be relative to the path of the gamelist file. Currently only relevant when generating an EmulationStation, a Retrobat or a Pegasus game list (see also [frontend](#frontend) option).
816816

817817
!!! info
818818

docs/PATHHANDLING.md

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
## Path Logic in Skyscraper
2+
3+
This page describes how Skyscraper processes the different paths and especially
4+
how the absolute path is calculated when a you provide a relative path.
5+
6+
Do not get confused by the lenghty flow diagram below. It covers gamelist folder,
7+
input folder and media folder handling. You wiil notice that input folder and
8+
media folder are processed in the same manner.
9+
10+
<figure markdown style="width:100%">
11+
<img style="width:100%" src="../resources/path_handling_flow.svg"/>
12+
<figcaption>Path processing flowchart</figcaption>
13+
</figure>
14+
15+
Ah, good you made it to the end of the flow.
16+
17+
Pay attention to the connectors _A-A_, _B-B_ and _C-C_ in the diagram.
18+
19+
_Normalization_ means any surplus `./` and `../` are removed from the path.
20+
However, at this stage it is not verified if the filepath does exists. Also, any
21+
symbolic links are not resolved.
22+
23+
Remember the precedence of [CLI and configuration
24+
options](CONFIGINI.md#configini-options) when you read through this document.
25+
26+
!!! tip "In a Nutshell"
27+
28+
Key takeaway is that a relative input folder and relative media folder are
29+
always calculated to an absolute folder in relation to the absolute gamelist
30+
folder. When you apply [`relativePaths="true"`](CONFIGINI.md#relativepaths),
31+
they will be generated with the relative path in respect to the gamelist-
32+
or metadata-output (in Pegasus terms) path.
33+
34+
Now, let's see how Skyscraper handles relative path configuration options.
35+
36+
### Computing the Absolute Path from ...
37+
38+
a relative path provided. The next subsections are summarizing the absolute path
39+
calculation of the different path and file options.
40+
41+
#### Current Working Directory
42+
43+
The current working directory (CWD) is the directory from where you run
44+
Skyscraper. The absolute path is computed as `<CWD>/<option-value>` for these
45+
CLI options and their values:
46+
47+
`-a <artwork.xml>`
48+
`-c <configfile>`
49+
`-g <gamelistfolder>`
50+
`-d <cachefolder>`
51+
52+
This means the first part of the flow diagram (Gamelist folder) also applies to
53+
`-a` and `-d` options and their configfile counterparts.
54+
55+
In contrast, when you provide these three (`<artwork.xml>`,`<gamelistfolder>`
56+
and `<cachefolder>`) in a configuration INI-file the absolute path it determined
57+
from the absolute path of the config file. See
58+
[below](#an-option-in-a-configuration-ini-file).
59+
60+
#### Skyscraper Built-in Config Directory
61+
62+
This is usually `/home/<USER>/.skyscraper/` (base). With [XDG](XDG.md) it is
63+
slightly different. The files provided with these options
64+
65+
`--excludeFrom <excludes.txt>`
66+
`--includeFrom <includes.txt>`
67+
68+
are searched in that directory by concatenating the base and for example the
69+
exclude file. If not found, Skyscraper tries to access them with the current
70+
working directory as base.
71+
72+
#### the Gamelist Folder
73+
74+
If you define a Gamelist folder either via `-g` or via `gameListFolder=`
75+
(INI-file) this is the base for the relative paths of
76+
77+
`-i <folder>` or `inputFolder=<folder>`
78+
`-o <folder>` or `mediaFolder=<folder>`
79+
80+
This is also depicted in the diagram above.
81+
82+
#### Input Folder (ROM-/gamefile-path)
83+
84+
The files provided with these options
85+
86+
`--startAt <game-file-A>`
87+
`--endAr <game-file-B>`
88+
89+
are first searched in the current working directory. If not found,
90+
Skyscraper tries to access them in the input folder.
91+
92+
#### an Option in a Configuration INI File
93+
94+
When you have set one of the following parameters in the default configuration
95+
file (`/home/<USER>/.skyscraper/config.ini`) or in a custom config file defined
96+
with `-c <configfile>` the path is calculated from the absolute path of
97+
the location of the config INI-file.
98+
99+
`artworkXml=<artwork.xml>`
100+
`gameListFolder=<gamelistfolder>`
101+
`cacheFolder<cachefolder>`
102+
`importFolder<importfolder>`
103+
104+
!!! note
105+
106+
The `importFolder=` parameter has no counterpart on the command line.
107+
108+
Remember, that this path calculation is different than the logic when using [CLI
109+
options](#current-working-directory).

docs/USECASE.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ Now, let's dig in!
1616

1717
You probably installed Skyscraper in order to get some data and artwork on your frontend game lists. So let's say that you have a bunch of Super Nintendo files you wish to populate with data. You'd first gather some data into the Skyscraper resource cache and then generate a game list using the cached data afterwards. So it's a two-step process.
1818

19-
![Skyscraper flowchart](resources/skyscraper_overview_chart.png)
19+
<figure markdown>
20+
![Skyscraper flowchart](resources/skyscraper_overview_chart.png)
21+
<figcaption>Skyscraper flowchart</figcaption>
22+
</figure>
2023

2124
#### The Gathering Phase
2225

docs/XDG.md

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,20 @@ has a brief section on the topic.
1717

1818
### File Locations: Genuine- and XDG-Skyscraper
1919

20-
| Type | Genuine Skyscraper Loation | XDG BDS Location |
21-
| :------: | --------------------------------------------------------------------- | -------------------------------------- |
22-
| CONFIG | All files, but no subfolders of `~/.skyscraper/*` | `$XDG_CONFIG_HOME/skyscraper/` |
23-
| CACHE | All of `~/.skyscraper/cache/` | `$XDG_CACHE_HOME/skyscraper/` |
24-
| IMPORT | All of `~/.skyscraper/import/` | `$XDG_DATA_HOME/skyscraper/import/` |
25-
| RESOURCE | All of `~/.skyscraper/resources/` | `$XDG_DATA_HOME/skyscraper/resources/` |
26-
| LOG | Skipped files/games during processing `~/.skyscraper/skipped*.txt` | `$XDG_STATE_HOME/skyscraper/` |
27-
| REPORT | Cache reports `~/.skyscraper/reports/*` | `$XDG_STATE_HOME/skyscraper/reports/` |
28-
| LOG | Rare Screenscraper Error Log `~/.skyscraper/screenscraper_error.json` | `$XDG_STATE_HOME/skyscraper/` |
29-
30-
As the per specifications: All paths must be absolute, relative paths will be
31-
ignored by Skyscraper. Non-existing paths will be created by Skyscraper.
20+
| Type | Genuine Skyscraper Location | XDG BDS Location |
21+
| :------: | -------------------------------------------------------------------- | -------------------------------------- |
22+
| CONFIG | All files, but no subfolders of `~/.skyscraper/*` | `$XDG_CONFIG_HOME/skyscraper/` |
23+
| CACHE | All of `~/.skyscraper/cache/` | `$XDG_CACHE_HOME/skyscraper/` |
24+
| IMPORT | All of `~/.skyscraper/import/` | `$XDG_DATA_HOME/skyscraper/import/` |
25+
| RESOURCE | All of `~/.skyscraper/resources/` | `$XDG_DATA_HOME/skyscraper/resources/` |
26+
| LOG | Skipped files/games during processing `~/.skyscraper/skipped*.txt` | `$XDG_STATE_HOME/skyscraper/` |
27+
| REPORT | Cache reports `~/.skyscraper/reports/*` | `$XDG_STATE_HOME/skyscraper/reports/` |
28+
| LOG | Rare Screenscraper error log `~/.skyscraper/screenscraper_error.txt` | `$XDG_STATE_HOME/skyscraper/` |
29+
30+
!!! warning "Skyscraper is strict"
31+
32+
As per specification: All paths must be absolute, relative paths will be
33+
ignored by Skyscraper. Non-existing paths will be created by Skyscraper.
3234

3335
### How to Enable XDG
3436

@@ -43,8 +45,8 @@ Skyscraper will be deploy its configuration files to the XDG destinations (by
4345
default sourced from `/usr/local/etc/skyscraper`).
4446

4547
If you want to verify if Skyscraper is compiled with XDG support run `Skyscraper
46-
--version`. If you see a XDG label below the version it means XDG is enabled and
47-
supported.
48+
--version`. If you see a XDG label below the version number it means XDG is
49+
enabled and supported.
4850

4951
To disable XDG support undo the steps above.
5052

docs/resources/path_handling_flow.drawio

Lines changed: 514 additions & 0 deletions
Large diffs are not rendered by default.

docs/resources/path_handling_flow.svg

Lines changed: 4 additions & 0 deletions
Loading

hints.xml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,13 @@
2929
<hint>You can pinpoint a game with the Mobygames scraper with "-s mobygames --query &lt;gameid&gt;", where the &lt;gameid&gt; is the ID listed on the mobygames site at the game's detail view.</hint>
3030
<hint>Skyscraper on Linux supports bash-completion (aka. programmable completion): Check the documentation at https://gemba.github.io/skyscraper/CLIHELP/#programmable-completion for details. Once enabled press TAB twice to display completion options.</hint>
3131
<hint>You can scrape game manuals with Skyscraper and display them if your frontend supports this. Use manuals=true in config.ini.</hint>
32-
<hint>You can make Skyscraper use the XDG Base Directories on Linux systems. See the XDG.md documentation.</hint>
32+
<hint>You can make Skyscraper use the XDG Base Directories on Linux systems. See the https://gemba.github.io/skyscraper/XDG documentation.</hint>
3333
<hint>Skyscraper supports the ES-DE frontend gamelist format.</hint>
34-
<hint>You can add new platforms (i.e., systems to scrape) with configuration file edits. See PLATFORMS.md.</hint>
34+
<hint>You can add new platforms (i.e., systems to scrape) with configuration file edits. See https://gemba.github.io/skyscraper/PLATFORMS</hint>
3535
<hint>You can scrape data from GameBase DB files with Skyscraper. GameBase DBs are a well of information especially for indie or homebrew games for retro systems.</hint>
3636
<hint>Skyscraper supports ten scraping modules: 7 for online sources and 3 for local sources.</hint>
3737
<hint>Pizza and beer go well together.</hint>
3838
<hint>Skyscraper debuted at June, 11th 2017.</hint>
39+
<hint>Skyscraper runs on Linux, macOS and Windows.</hint>
40+
<hint>You can use relative paths for almost every path related option. See https://gemba.github.io/skyscraper/PATHHANDLING</hint>
3941
</hints>

0 commit comments

Comments
 (0)