Filesystem tools
This commit is contained in:
parent
7e7b46c36b
commit
c339f1ea08
2 changed files with 42 additions and 3 deletions
39
mcfs.py
Normal file
39
mcfs.py
Normal file
|
@ -0,0 +1,39 @@
|
|||
import os
|
||||
from sys import platform
|
||||
|
||||
def __get_mc_dir():
|
||||
directory = ""
|
||||
if platform == 'linux':
|
||||
home = os.getenv("HOME", "")
|
||||
directory = home + "/.minecraft"
|
||||
elif platform == 'win32':
|
||||
appdata = os.getenv('APPDATA')
|
||||
directory = appdata + r"\.minecraft"
|
||||
elif platform == "darwin":
|
||||
directory = "~/Library/Application Support/minecraft" #unsure
|
||||
directory = os.getenv("MC_DIR", directory)
|
||||
return directory
|
||||
|
||||
def __get_cache_dir():
|
||||
directory = ""
|
||||
if platform == 'win32':
|
||||
appdata_local = os.getenv("LOCALAPPDATA")
|
||||
directory = appdata_local + r"\mc-get"
|
||||
elif platform == 'darwin':
|
||||
directory = '~/Library/Caches/mc-get' #unsure
|
||||
elif platform == 'linux':
|
||||
cache = os.getenv("HOME") + "/.cache"
|
||||
directory = cache + "/mc-get"
|
||||
else:
|
||||
cache = os.getenv("XDG_CACHE_HOME", "")
|
||||
directory = cache + "/mc-get"
|
||||
return directory
|
||||
|
||||
def is_path_exist(path:str):
|
||||
return os.path.exists(os.path.join(path))
|
||||
|
||||
def is_standart_dir_structure():
|
||||
return not os.path.exists(os.path.join(directory, "home"))
|
||||
|
||||
mc_dir = __get_mc_dir()
|
||||
cache_dir = __get_cache_dir()
|
Loading…
Add table
Add a link
Reference in a new issue