mc-get/mcfs.py

44 lines
1.3 KiB
Python

import os
from sys import platform
import shutil
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"))
def install(filename, subdir:str):
shutil.copy2(os.path.join(cache_dir,filename),\
os.path.join(mc_dir,subdir,filename))
mc_dir = __get_mc_dir()
cache_dir = __get_cache_dir()