Store configuration in user configuration directory

This commit is contained in:
Yohann D'ANELLO
2020-11-19 03:13:01 +01:00
parent 00f843754a
commit 0fbbf4925d
3 changed files with 18 additions and 6 deletions

View File

@ -7,7 +7,15 @@ class ResourceManager:
and stores files in config directory.
"""
BASE_DIR = Path(__file__).resolve().parent / 'assets'
# FIXME This might not work on not-UNIX based systems.
CONFIG_DIR = Path.home() / '.config' / 'squirrel-battle'
@classmethod
def get_asset_path(cls, filename: str) -> str:
return str(cls.BASE_DIR / filename)
@classmethod
def get_config_path(cls, filename: str) -> str:
cls.CONFIG_DIR.mkdir(parents=True) if not cls.CONFIG_DIR.is_dir() \
else None
return str(cls.CONFIG_DIR / filename)