Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Windows users to have user-specific data directories. #250

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions edkrepo/config/config_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

def get_edkrepo_global_data_directory():
global_data_dir = None
user_data_dir = None
if sys.platform == "win32":
shell32 = oledll.shell32
SHGetFolderPath = shell32.SHGetFolderPathW
Expand All @@ -36,11 +37,14 @@ def get_edkrepo_global_data_directory():
common_appdata = create_unicode_buffer(MAX_PATH)
SHGetFolderPath(None, CSIDL_COMMON_APPDATA, None, SHGFP_TYPE_CURRENT, common_appdata)
global_data_dir = os.path.join(common_appdata.value, "edkrepo")
user_data_dir = os.path.expanduser(os.path.join("~", "edkrepo"))
elif sys.platform == "darwin" or sys.platform.startswith("linux") or os.name == "posix":
global_data_dir = expanduser("~/.edkrepo")
if not os.path.isdir(global_data_dir):
if not os.path.exists(os.path.dirname(global_data_dir)):
raise EdkrepoGlobalDataDirectoryNotFoundException(humble.GLOBAL_DATA_DIR_NOT_FOUND.format(os.path.dirname(global_data_dir)))
if sys.platform == "win32" and os.path.isdir(user_data_dir):
return user_data_dir
os.mkdir(global_data_dir)
return global_data_dir

Expand Down