mirror of
https://git.triforceproject.com/triforce/source
synced 2026-11-19 16:20:01 -04:00
Triforce v0.2.0
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
45
builder/py/hookshot_builder/paths.py
Normal file
45
builder/py/hookshot_builder/paths.py
Normal file
@@ -0,0 +1,45 @@
|
||||
"""Where things are: the builder's own folder in %LOCALAPPDATA%, and this app's folder."""
|
||||
import os
|
||||
import sys
|
||||
|
||||
APP_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
ASSETS = os.path.join(APP_DIR, "assets")
|
||||
|
||||
|
||||
def base():
|
||||
"""%LOCALAPPDATA%\\HookshotBuilder (HOOKSHOT_SETUP_BASE=<folder>: another, for testing installs and updates)"""
|
||||
b = os.environ.get("HOOKSHOT_SETUP_BASE")
|
||||
if b:
|
||||
return b
|
||||
return os.path.join(os.environ.get("LOCALAPPDATA") or os.path.expanduser("~"), "HookshotBuilder")
|
||||
|
||||
|
||||
def versions():
|
||||
return os.path.join(base(), "versions")
|
||||
|
||||
|
||||
def read_small(path):
|
||||
try:
|
||||
with open(path, encoding="utf-8", errors="replace") as f:
|
||||
return f.read().strip()
|
||||
except OSError:
|
||||
return ""
|
||||
|
||||
|
||||
def write_small(path, text):
|
||||
try:
|
||||
os.makedirs(os.path.dirname(path), exist_ok=True)
|
||||
with open(path, "w", encoding="utf-8", newline="\n") as f:
|
||||
f.write(text)
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
|
||||
def launcher_command():
|
||||
"""How this app is started again (the game folder's launcher, the game's update offer, a shortcut): the Python that runs it
|
||||
(pythonw.exe beside python.exe when there is one: no console window) and the app's start script"""
|
||||
exe = sys.executable
|
||||
w = os.path.join(os.path.dirname(exe), "pythonw.exe")
|
||||
if os.path.isfile(w):
|
||||
exe = w
|
||||
return exe, ["-I", os.path.join(os.path.dirname(APP_DIR), "hookshot_builder_start.py")]
|
||||
Reference in New Issue
Block a user