|
|
|
@ -5,6 +5,7 @@ Common helper and cache for pwndbg tempdir
|
|
|
|
from __future__ import annotations
|
|
|
|
from __future__ import annotations
|
|
|
|
|
|
|
|
|
|
|
|
import os
|
|
|
|
import os
|
|
|
|
|
|
|
|
import sys
|
|
|
|
import tempfile
|
|
|
|
import tempfile
|
|
|
|
|
|
|
|
|
|
|
|
import pwndbg.lib.cache
|
|
|
|
import pwndbg.lib.cache
|
|
|
|
@ -22,12 +23,15 @@ def tempdir() -> str:
|
|
|
|
def cachedir(namespace: str | None = None) -> str:
|
|
|
|
def cachedir(namespace: str | None = None) -> str:
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
Returns and potentially creates a persistent safe cachedir location
|
|
|
|
Returns and potentially creates a persistent safe cachedir location
|
|
|
|
based on XDG_CACHE_HOME or ~/.cache
|
|
|
|
based on XDG_CACHE_HOME or ~/.cache or LOCALAPPDATA (Windows)
|
|
|
|
|
|
|
|
|
|
|
|
Optionally creates a sub namespace inside the pwndbg cache folder.
|
|
|
|
Optionally creates a sub namespace inside the pwndbg cache folder.
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
|
|
|
|
if sys.platform == "win32":
|
|
|
|
|
|
|
|
cachehome = os.getenv("LOCALAPPDATA")
|
|
|
|
|
|
|
|
else:
|
|
|
|
cachehome = os.getenv("XDG_CACHE_HOME") or os.path.join(os.getenv("HOME", ""), ".cache")
|
|
|
|
cachehome = os.getenv("XDG_CACHE_HOME") or os.path.join(os.getenv("HOME", ""), ".cache")
|
|
|
|
cachedir = os.path.join(cachehome, "pwndbg")
|
|
|
|
cachedir = os.path.join(cachehome or tempfile.gettempdir(), "pwndbg")
|
|
|
|
if namespace:
|
|
|
|
if namespace:
|
|
|
|
cachedir = os.path.join(cachedir, namespace)
|
|
|
|
cachedir = os.path.join(cachedir, namespace)
|
|
|
|
os.makedirs(cachedir, exist_ok=True)
|
|
|
|
os.makedirs(cachedir, exist_ok=True)
|
|
|
|
|