Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] Expand the path name of the per-content-directory-override-config-file #12021

Open
Kupo91 opened this issue Feb 11, 2021 · 5 comments
Labels
feature request New enhancement to RetroArch.

Comments

@Kupo91
Copy link

Kupo91 commented Feb 11, 2021

My problem is that this config file only works for the folder in which my rom is directly placed.

To give you a better understanding what I mean, here is an example: My folder structure looks like that:

Games

  • Gameboy
    • Artworks
    • Savegames
      • (Name of the game).srm
      • (Name of the game).state
    • Roms
      • Asterix
        • Asterix.gb
      • Pokemon Red
        • Pokemon Red.gb
  • Gameboy Color
  • Gameboy Advance
  • and so on

As you see I don't have one savegame folder for all savegames, but separated by platforms.
My first attempt was to use the core-override-config-file to set an individual savegame path for each platform.
But then I realized that there are cores like Gambatte which are used for two or more platforms (GB & GBC).
So this won't work, since I can set only one savegame path per core and I would need two savegame paths in this case.
Then I discoverd the directory-override-config-option which is actually exactly what I need in this case.
But the problem is that the "directory" is limited on the folder in which my rom is directly placed.
So instead creating a config file which counts for all contents of the "Roms" folder, it only creates a config file which counts for the folder "Asterix" since this is the next higher folder of the content which I've loaded.
The name of the config file would be "Asterix.cfg"

What I need is a config file named like "Z-Games-Gameboy-Roms.cfg", which counts for all contents in the directory "Z:\Games\Gameboy\Roms"

This would make this override option much more useful in my opinion.

@thingsiplay
Copy link

I have a need for content-directory for subfolders too. There are two use cases for me:

  1. Subfolder problem: Without subfolder support, I have to put all roms and msu-1 files in the same folder, because the settings are for the parent folder only. But I like to organize it like this:

    • mods_msu-1
      • Super Metroid (MSU-1)
        • Super Metroid.sfc
        • Super Metroid-1.pcm
        • ...

I would like to have a method to apply the content-directory-override to mods_msu-1 once.

  1. Same name problem: Also I have a separate unofficial folder for many systems, with multiple subfolders (mods, translations, homebrew, msu-1 and so on). This can be a problem for multi system emulation. Now if the subfolder is just called "mods" for gb games and for gbc games, then applying content-directory to gb will create a mods.cfg file and I can't create one that is different for gbc, as both directories share the same name.

As a workaround for this one, I have to create unique subfolder names, that are unique to the entire collection, in example gb_mods. This is tedious and requires all playlists to be updated.

So I highly support your request and would make my life much easier to work with this.

@LibretroAdmin LibretroAdmin added the feature request New enhancement to RetroArch. label Sep 3, 2022
@zrooda
Copy link

zrooda commented Dec 22, 2023

Just came across the same issue with my Sega CD collection, +1 to the request. IMO Content Directory applying to all subfolders is sane default.

@schmurtzm
Copy link

Same issue here : I have a "Content Directory Overrides" which doesn't work with subfolder.
I've scripted my own workaround : it takes the parent directory and tries to find the corresponding directory config override.

It works great but there is an exception : if multiple directory config override are found, it will try to find the right config file thanks to the core name, but the problem is that there is a lack of standardization on RA cores : the config folder doesn't always correspond to the core file name 😕 (for example gw_libretro.so core will save its config in "config/Game & Watch" folder). You'll find similar difficulties in scripting with saves or savestates, the lack of standardization is often a problem to automatize some tasks.

I share my script here, may be some of you will find it useful :

My emu launch script :

#!/bin/sh
RA_DIR=/mnt/SDCARD/RetroArch
cd $RA_DIR/
source /mnt/SDCARD/RetroArch/FolderOverrideFinder.sh
HOME=$RA_DIR/ $RA_DIR/retroarch -v -L $RA_DIR/.retroarch/cores/gambatte_libretro.so "$@"

My directory config override finder (FolderOverrideFinder.sh) :

subdir_count=$(echo "$1" | awk -F'/Roms/' '{print $2}' | awk -F'/' '{print NF-1}') # Count the number of slashes in the rest of the path

if [ "$subdir_count" -gt 1 ]; then
    if [ -z "$2" ]; then # the override is not already defined
        echo "############### Folder Overrride Finder ###############"
        first_subdir=$(echo "$1" | awk -F'/Roms/' '{print $2}' | cut -d'/' -f1) # Use awk to extract the part of the path after "/mnt/SDCARD/Roms/" to the next "/".
        echo "Subdirectory from $first_subdir detected !"

        # we try to find the folder override
        result=$(find /mnt/SDCARD/RetroArch/.retroarch/config/ -name "$first_subdir.cfg")

        num_lines=$(echo "$result" | wc -l)

        if [ $num_lines -eq 1 ]; then
            FolderOverride="$result"
        else
            # if we find multiple folder override config files, we try to find the right one depending the core name
            core_name=$(grep '^[[:space:]]*HOME=' "$0" | grep '_libretro\.so' | sed -E 's/.*cores\/([^_]+)_libretro\.so.*/\1/')
            core_config=$(echo "$result" | grep -i "$core_name")

            if [ -z "$core_config" ]; then
                FolderOverride="" # We didn't found it  (we avoid to select one by default : FolderOverride=$(echo "$result" | head -n 1))
            else
                FolderOverride="$core_config"
            fi

            echo "Roms root directory: $first_subdir"
            echo core_name: $core_name
        fi

        if [ ! -z "$FolderOverride" ]; then
            echo "Folder override found: $FolderOverride"
            echo "#######################################################"
            source "$0" "$1" --appendconfig "$FolderOverride"
            exit
        else
            echo "Folder override not found"
            echo "#######################################################"
        fi
        
    fi
else
    echo "No subdirectory detected."
fi

You'll probably need to adapt it to your case because :

  • it uses "/mnt/SDCARD/RetroArch" as default RA folder
  • it find the RA launch command line which starts with "HOME="
  • Root roms folder is "Roms" (key sensitive)

@schmurtzm
Copy link

Deeply reworked for a more reliable result : now I use a core database made by my own : it indicates for a core filename the corresponding config path.

My updated directory config override finder (FolderOverrideFinder.sh) :

subdir_count=$(echo "$1" | awk -F'/Roms/' '{print $2}' | awk -F'/' '{print NF-1}') # Count the number of slashes in the rest of the path

if [ "$subdir_count" -gt 1 ]; then
    if [ -z "$2" ]; then # the override config file is not already defined
        echo "############### Folder Overrride Finder ###############"
        first_subdir=$(echo "$1" | awk -F'/Roms/' '{print $2}' | cut -d'/' -f1) # Use awk to extract the part of the path after "/mnt/SDCARD/Roms/" to the next "/".
        echo "Subdirectory from $first_subdir detected !"

        # We try to find the config folder :
        core_filename=$(grep '^[[:space:]]*HOME=' "$0" | grep '_libretro\.so' | sed -E 's/.*cores\/([^\/]+\.so).*/\1/')  # we find the core filename in the launch script itself
        core_folder=$(grep -m 1 "$core_filename" /mnt/SDCARD/core_folders.csv | cut -d';' -f2) # we use a core database which indicates for a core filename the corresponding config path
        echo "The core folder for $core_filename is: $core_folder"

        if [ -f "/mnt/SDCARD/RetroArch/.retroarch/config/$core_folder/$first_subdir.cfg" ]; then
            FolderOverride="/mnt/SDCARD/RetroArch/.retroarch/config/$core_folder/$first_subdir.cfg"
        else
            # we try to find the folder override without the core database
            result=$(find /mnt/SDCARD/RetroArch/.retroarch/config/ -name "$first_subdir.cfg")
            num_lines=$(echo "$result" | wc -l)

            if [ $num_lines -eq 1 ]; then
                FolderOverride="$result"
            else
                # if we find multiple folder override config files, we try to find the right one depending the core name
                core_name=$(grep '^[[:space:]]*HOME=' "$0" | grep '_libretro\.so' | sed -E 's/.*cores\/([^\/]+)_libretro\.so.*/\1/' | cut -d'_' -f1)
                result=$(echo "$result" | grep -i "$core_name/")
                num_lines=$(echo "$result" | wc -l)
                if [ $num_lines -eq 1 ]; then
                    FolderOverride="$result"
                else
                    if [ $num_lines -ne 0 ]; then
                        # less restrictive comparison  :
                        result=$(echo "$result" | grep -i "$core_name")
                        num_lines=$(echo "$result" | wc -l)
                        if [ $num_lines -eq 1 ]; then
                            FolderOverride="$result" #  (we avoid to select one by default : FolderOverride=$(echo "$result" | head -n 1))
                        elif [ $num_lines -gt 1 ]; then
                            echo "Multiple possibilities found, none selected"
                        fi

                    fi
                fi
            fi
        fi

        if [ ! -z "$FolderOverride" ]; then

            echo "Folder override found: $FolderOverride"
            echo "#######################################################"
            source "$0" "$1" --appendconfig "$FolderOverride"
            exit
        else
            echo "Folder override not found"
            echo "#######################################################"
        fi

    fi
else
    echo "No subdirectory detected."
fi

The database (which could be useful for other scripts too), core_folders.csv :

2048_libretro.so;2048;
81_libretro.so;EightyOne;
DoubleCherryGB_libretro.so;DoubleCherryGB;
a5200_libretro.so;a5200;
arduous_libretro.so;arduous;
atari800_libretro.so;Atari800;
bash_launcher_libretro.so;
bk_libretro.so;
bluemsx_libretro.so;blueMSX;
bnes_libretro.so;bnes;
cannonball_libretro.so;Cannonball;
cap32_libretro.so;cap32;
chailove_libretro.so;ChaiLove;
craft_libretro.so;Craft;
crocods_libretro.so;crocods;
daphne_libretro.so;Daphne;
desmume2015_libretro.so;DeSmuME 2015;
dinothawr_libretro.so;Dinothawr;
dosbox_libretro.so;DOSBox;
dosbox_pure_libretro.so;DOSBox-pure;
dosbox_svn_libretro.so;
duckstation_libretro.so;DuckStation;
easyrpg_libretro.so;EasyRPG Player;
ecwolf_libretro.so;ecwolf;
ep128emu_core_libretro.so;ep128emu;
fake08_libretro.so;fake-08;
fbalpha2012_cps1_libretro.so;FB Alpha 2012 CPS-1;
fbalpha2012_cps2_libretro.so;FB Alpha 2012 CPS-2;
fbalpha2012_cps3_libretro.so;FB Alpha 2012 CPS-3;
fbalpha2012_libretro.so;FB Alpha 2012;
fbalpha2012_neogeo_libretro.so;FB Alpha 2012 Neo Geo;
fbalpha_libretro.so;FB Alpha 2012;
fbneo_libretro.so;FinalBurn Neo;
fceumm_libretro.so;FCEUmm;
fceunext_libretro.so;FCEUmm;
fly_flycast_libretro.so;Flycast;
flycast_libretro.so;Flycast;
flycast_rumble_libretro.so;Flycast;
fmsx_libretro.so;fMSX;
freechaf_libretro.so;FreeChaF;
freeintv_libretro.so;FreeIntv;
freej2me_libretro.so;
fuse_libretro.so;fuse;
gambatte_gb_libretro.so;Gambatte;
gambatte_libretro.so;Gambatte;
gearboy_libretro.so;Gearboy;
gearcoleco_libretro.so;Gearcoleco;
gearsystem_libretro.so;Gearsystem;
genesis_plus_gx_libretro.so;Genesis Plus GX;
genesis_plus_gx_wide_libretro.so;Genesis Plus GX;
geolith_libretro.so;Geolith;
gme_libretro.so;Game Music Emulator;
gpsp_libretro.so;gpSP;
gw_libretro.so;Game & Watch;
handy_libretro.so;Handy;
hatari_libretro.so;Hatari;
imageviewer_libretro.so;image display;
libfceumm.so;
libmgba.so;
lowresnx_libretro.so;LowRes NX;
lutro_libretro.so;lutro;
mame2000_libretro.so;MAME 2000;
mame2003_libretro.so;MAME 2003 (0.78);
mame2003_plus_libretro.so;MAME 2003-Plus;
mame2010_libretro.so;MAME 2010;
mame2015_libretro.so;MAME 2015;
mame_libretro.so;MAME;
mamearcade2016_libretro.so;MAME 2016;
mamearcade_libretro.so;MAME;
mednafen_gba_libretro.so;Beetle GBA;
mednafen_gba_libretro_libretro.so;Beetle GBA;
mednafen_lynx_libretro.so;Beetle Lynx;
mednafen_ngp_libretro.so;Beetle NeoPop;
mednafen_pce_fast_libretro.so;Beetle PCE Fast;
mednafen_pcfx_libretro.so;Beetle PC-FX;
mednafen_supafaust_libretro.so;Supafaust;
mednafen_supergrafx_libretro.so;Beetle SuperGrafx;
mednafen_vb_libretro.so;Beetle VB;
mednafen_wswan_libretro.so;Beetle WonderSwan;
melonds_libretro.so;melonDS;
mesen_libretro.so;Mesen;
mess2015_libretro.so;MESS 2015;
mess_libretro.so;MAME;
meteor_libretro.so;Meteor GBA;
mgba_libretro.so;mGBA;
mgba_rumble_libretro.so;/mGBA;
minivmac_libretro.so;Mini vMac;
mpv_libretro.so;
mrboom_libretro.so;Mr.Boom;
mu_libretro.so;Mu;
mupen64plus_libretro.so;Mupen64Plus GLES2;
mupen64plus_next_libretro.so;
nekop2_libretro.so;Neko Project II;
neocd_libretro.so;NeoCD;
nestopiaCV_libretro.so;
nestopia_libretro.so;Nestopia;
np2kai_libretro.so;Neko Project II kai;
numero_libretro.so;Numero;
nxengine_libretro.so;NXEngine;
o2em_libretro.so;O2EM;
onscripter_libretro.so;onscripter;
opera_libretro.so;Opera;
parallel_n64_libretro.so;ParaLLEl N64;
pcsx_rearmed_libretro.so;PCSX-ReARMed;
pcsx_rearmed_libretro_old.so;PCSX-ReARMed;
pcsx_rearmed_libretro_shaun.so;PCSX-ReARMed;
pcsx_rearmed_rumble_libretro.so;PCSX-ReARMed;
picodrive_libretro.so;PicoDrive;
pokemini_libretro.so;PokeMini;
potator_libretro.so;Potator;
ppsspp_libretro.so;PPSSPP;
prboom_libretro.so;PrBoom;
prosystem_libretro.so;ProSystem;
puae2021_libretro.so;PUAE 2021;
puae_libretro.so;PUAE;
px68k_libretro.so;PX68K;
quasi88_libretro.so;QUASI88;
quicknes_libretro.so;QuickNES;
race_libretro.so;RACE;
reminiscence_libretro.so;REminiscence;
retro8_libretro.so;retro-8 (alpha);
same_cdi_libretro.so;
sameboy_libretro.so;SameBoy;
sameduck_libretro.so;;
scummvm_libretro.so;scummvm;
scummvm_libretro1.so;scummvm;
snes9x2002_libretro.so;Snes9x 2002;
snes9x2005_libretro.so;Snes9x 2005;
snes9x2005_plus_libretro.so;Snes9x 2005 Plus;
snes9x2010_libretro.so;Snes9x 2010;
snes9x_libretro.so;Snes9x;
snes9x_next_libretro.so;
squirreljme_libretro.so;
stella2014_libretro.so;Stella 2014;
stella_libretro.so;Stella;
superflappybirds_libretro.so;Super Flappy Birds;
swanstation_libretro.so;SwanStation;
tgbdual_libretro.so;TGB Dual;
theodore_libretro.so;theodore;
tic80_libretro.so;TIC-80;
tyrquake_libretro.so;TyrQuake;
uae4arm_libretro.so;uae4arm;
uzem_libretro.so;Uzem;
vba_next_libretro.so;VBA Next;
vbam_libretro.so;VBA-M;
vecx_libretro.so;VecX;
vemulator_libretro.so;VeMUlator;
vice_x128_libretro.so;VICE x128;
vice_x64_libretro.so;VICE x64;
vice_x64dtv_libretro.so;
vice_x64sc_libretro.so;VICE x64sc;
vice_xcbm2_libretro.so;VICE xcbm2;
vice_xcbm5x0_libretro.so;VICE xcbm5x0;
vice_xpet_libretro.so;VICE xpet;
vice_xplus4_libretro.so;VICE xplus4;
vice_xscpu64_libretro.so;VICE xscpu64;
vice_xvic_libretro.so;VICE xvic;
virtualjaguar_libretro.so;Virtual Jaguar;
wasm4_libretro.so;WASM-4;
x1_libretro.so;x1;
xrick_libretro.so;xrick;
yabasanshiro_libretro.so;YabaSanshiro;
yabause_libretro.so;Yabause;

(the emu launch script has not changed)

@thingsiplay
Copy link

@schmurtzm I personally would not use this script, because I am experienced enough to create my own solution. Just wanted say that I admire other peoples scripting solutions to small problems like these. But this probably should be in its own repository or at least Gist that can be linked.

Without looking into the details too much, I have an advice that I use doing manually for subfolders. You can just link a .cfg file with ln -s command. This way you only need to do this once and if the main .cfg file changes, it affects automatically all linked files. Also if you want this to be usable by others, then variables for paths is recommended, for easy customization.

cizia64 added a commit to cizia64/CrossMix-OS that referenced this issue May 28, 2024
Adding FolderOverrideFinder.sh from Schmurtz :
libretro/RetroArch#12021 (comment)

Make the directory override work in the subolders.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New enhancement to RetroArch.
Projects
None yet
Development

No branches or pull requests

5 participants