-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpaths.py
More file actions
64 lines (48 loc) · 1.81 KB
/
Copy pathpaths.py
File metadata and controls
64 lines (48 loc) · 1.81 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
56
57
58
59
60
61
62
63
64
"""
Centralized path management for ClawTreeViewPackage.
Single source of truth for all paths and directory creation.
"""
import sys
from pathlib import Path
class PackagePathManager:
"""
Centralized path management for ClawTreeViewPackage.
All folder creation logic is consolidated here.
"""
def __init__(self):
self.is_frozen = getattr(sys, 'frozen', False)
if self.is_frozen:
self.package_root = Path(sys.executable).parent
else:
self.package_root = Path(__file__).parent
# State persistence directory
self.state_dir = self.package_root / "_state"
# State file for UI persistence (expansion state, etc.)
self.state_file = self.state_dir / "ui_state.json"
# Cache directory for thumbnails, rendered pixmaps, etc.
self.cache_dir = self.state_dir / "cache"
# Thumbnail cache subdirectory
self.thumbnail_cache_dir = self.cache_dir / "thumbnails"
def ensure_directories(self):
"""
Create all required directories if they don't exist.
This is THE ONLY place where directories should be created.
"""
required_directories = [
self.state_dir,
self.cache_dir,
self.thumbnail_cache_dir,
]
for directory in required_directories:
directory.mkdir(parents=True, exist_ok=True)
def get_state_file(self) -> Path:
"""Get path to the UI state persistence file."""
return self.state_file
def get_cache_dir(self) -> Path:
"""Get path to the cache directory."""
return self.cache_dir
def get_thumbnail_cache_dir(self) -> Path:
"""Get path to the thumbnail cache directory."""
return self.thumbnail_cache_dir
# Singleton instance
PATHS = PackagePathManager()