forked from Diftic/SC_Signature_Scanner
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpaths.py
More file actions
55 lines (41 loc) · 1.56 KB
/
Copy pathpaths.py
File metadata and controls
55 lines (41 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/usr/bin/env python3
"""
Path utilities for SC Signature Scanner.
Handles paths correctly for both development and PyInstaller frozen builds.
"""
import sys
from pathlib import Path
def get_base_path() -> Path:
"""Get the base path for the application.
When running as a PyInstaller bundle, this returns the temp folder
where files are extracted. When running normally, returns the
directory containing this file.
"""
if getattr(sys, 'frozen', False) and hasattr(sys, '_MEIPASS'):
# Running as PyInstaller bundle
return Path(sys._MEIPASS)
else:
# Running as normal Python script
return Path(__file__).parent
def get_data_path() -> Path:
"""Get the path to the data directory."""
return get_base_path() / "data"
def get_user_data_path() -> Path:
"""Get the path for user data (configs, cache, etc).
This is always the directory containing the executable or script,
so user data persists between runs.
"""
if getattr(sys, 'frozen', False):
# Running as PyInstaller bundle - use exe directory
return Path(sys.executable).parent
else:
# Running as normal Python script
return Path(__file__).parent
def get_asset_path(asset_name: str) -> Path:
"""Get the path to an asset file."""
return get_base_path() / "assets" / asset_name
def get_debug_path() -> Path:
"""Get the path for debug output.
Returns a folder next to the executable (or script) for bug reports.
"""
return get_user_data_path() / "SignatureScannerBugreport"