diff --git a/RomM/filesystem.py b/RomM/filesystem.py index 4bf9f7f..e7290b7 100644 --- a/RomM/filesystem.py +++ b/RomM/filesystem.py @@ -46,6 +46,11 @@ def __init__(self) -> None: base_path = os.path.abspath(os.path.join(os.getcwd(), "..", "..")) # Default to the ROMs directory, overridable via environment variable self._sd1_roms_storage_path = os.environ.get("ROMS_STORAGE_PATH", base_path) + # For non-MuOS/non-SpruceOS devices, use catalogue from environment or create one in the app directory + self._sd1_catalogue_path = os.environ.get( + "CATALOGUE_PATH", + os.path.join(os.getcwd(), "catalogue") + ) # Ensure the ROMs storage path exists if self._sd2_roms_storage_path and not os.path.exists( @@ -56,6 +61,15 @@ def __init__(self) -> None: except FileNotFoundError: print("Cannot create SD2 storage path", self._sd2_roms_storage_path) + # Ensure the catalogue path exists + if self._sd1_catalogue_path and not os.path.exists(self._sd1_catalogue_path): + try: + os.makedirs(self._sd1_catalogue_path, exist_ok=True) + print(f"Created catalogue directory: {self._sd1_catalogue_path}") + except Exception as e: + print(f"Cannot create catalogue directory {self._sd1_catalogue_path}: {e}") + self._sd1_catalogue_path = None + # Set the default SD card based on the existence of the storage path self._current_sd = int( os.getenv(