aboutsummaryrefslogtreecommitdiffstats
path: root/cogs/utils/temp.py
blob: 528d6a3d5001baaf18a5bf28b2190b6bbaa0c3d8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# This file is part of Senator Sperma
# Licensed under the GPL-3.0 License
# Copyright (C) 2026 Salmonik @ salmonik@tuta.io
# https://codeberg.org/salmonik/senator-sperma

import os
import tempfile

def get_temp_dir(subdir: str = "senator_sperma") -> str:
    """Get or create a temp subdirectory.
    
    Uses system temp directory (/tmp on Linux, %TEMP% on Windows).
    OS handles cleanup automatically.
    """
    base_temp = tempfile.gettempdir()
    temp_path = os.path.join(base_temp, subdir)
    os.makedirs(temp_path, exist_ok=True)
    return temp_path