Skip to content

Commit 58c0e28

Browse files
authored
Merge pull request #58 from ZFordDev/52-storage-directory-db-file-location-appdirs-integration
feat: file resolver
2 parents 5e0369b + e68d9e7 commit 58c0e28

2 files changed

Lines changed: 43 additions & 0 deletions

File tree

src/storage/__init__.py

Whitespace-only changes.

src/storage/paths.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
"""
2+
paths.py
3+
--------
4+
Cross-platform storage path resolver for SchedPlus.
5+
6+
This module defines where persistent data is stored, including:
7+
- SQLite database file
8+
- Legacy JSON file (for migration)
9+
"""
10+
11+
import os
12+
from appdirs import user_data_dir
13+
14+
15+
APP_NAME = "SchedPlus"
16+
APP_AUTHOR = "ZFordDev" # optional, used on Windows
17+
18+
19+
def resolve_storage_dir() -> str:
20+
"""
21+
Returns the directory where SchedPlus stores all persistent data.
22+
Creates the directory if it does not exist.
23+
"""
24+
path = user_data_dir(APP_NAME, APP_AUTHOR)
25+
26+
if not os.path.exists(path):
27+
os.makedirs(path, exist_ok=True)
28+
29+
return path
30+
31+
32+
def get_db_path() -> str:
33+
"""
34+
Returns the full path to the SQLite database file.
35+
"""
36+
return os.path.join(resolve_storage_dir(), "schedplus.db")
37+
38+
39+
def get_json_path() -> str:
40+
"""
41+
Returns the full path to the legacy JSON file (for migration).
42+
"""
43+
return os.path.join(resolve_storage_dir(), "tasks.json")

0 commit comments

Comments
 (0)