Enhance grabbing of user data folder

This commit is contained in:
Fierelier 2021-03-18 17:55:14 +01:00
parent e6d6b2d62b
commit 23ce47df41
1 changed files with 6 additions and 3 deletions

View File

@ -44,11 +44,14 @@ def runScript(sf, lcs = False):
def getDataDir(appName):
basePath = False
if sys.platform.startswith("win"):
basePath = os.environ["appdata"]
if "appdata" in os.environ: basePath = os.environ["appdata"]
elif sys.platform.startswith("linux"):
basePath = os.environ["XDG_DATA_HOME"]
if "XDG_DATA_HOME" in os.environ:
basePath = os.environ["XDG_DATA_HOME"]
else:
if "HOME" in os.environ: basePath = p(os.environ["HOME"],".config")
elif sys.platform.startswith("darwin"):
basePath = os.path.join(os.environ["home"],"Library","Application Support")
if "HOME" in os.environ: basePath = p(os.environ["HOME"],"Library","Application Support")
if not basePath: raise
return p(basePath,appName)