@@ -35,43 +35,11 @@ def _get_base_path(self) -> Path:
3535 if getattr (sys , 'frozen' , False ):
3636 # Running as PyInstaller bundle
3737 if os .name == 'nt' : # Windows
38- import ctypes
39-
40- # Define HRESULT manually for PyInstaller compatibility
41- try :
42- from ctypes import wintypes
43- HRESULT = wintypes .HRESULT
44- except AttributeError :
45- # PyInstaller sometimes doesn't include all wintypes
46- HRESULT = ctypes .c_long
47-
48- CSIDL_LOCAL_APPDATA = 0x001c
49- SHGetFolderPath = ctypes .windll .shell32 .SHGetFolderPathW
50-
51- try :
52- from ctypes import wintypes
53- SHGetFolderPath .argtypes = [wintypes .HWND , ctypes .c_int , wintypes .HANDLE , wintypes .DWORD , wintypes .LPCWSTR ]
54- SHGetFolderPath .restype = HRESULT
55-
56- path_buf = ctypes .create_unicode_buffer (wintypes .MAX_PATH )
57- result = SHGetFolderPath (0 , CSIDL_LOCAL_APPDATA , 0 , 0 , path_buf )
58-
59- if result == 0 :
60- return Path (path_buf .value ) / "Echo"
61- else :
62- return Path .home () / "AppData" / "Local" / "Echo"
63- except AttributeError :
64- # Fallback if wintypes are not available
65- SHGetFolderPath .argtypes = [ctypes .c_void_p , ctypes .c_int , ctypes .c_void_p , ctypes .c_uint , ctypes .c_wchar_p ]
66- SHGetFolderPath .restype = HRESULT
67-
68- path_buf = ctypes .create_unicode_buffer (260 ) # MAX_PATH
69- result = SHGetFolderPath (0 , CSIDL_LOCAL_APPDATA , 0 , 0 , path_buf )
70-
71- if result == 0 :
72- return Path (path_buf .value ) / "Echo"
73- else :
74- return Path .home () / "AppData" / "Local" / "Echo"
38+ appdata = os .environ .get ('LOCALAPPDATA' )
39+ if appdata :
40+ return Path (appdata ) / "Echo"
41+ else :
42+ return Path .home () / "AppData" / "Local" / "Echo"
7543 else :
7644 return Path .home () / ".echo"
7745 else :
0 commit comments