Filesystem Paths

torii.util.directories.TORII_PLATFORM_DIRS: Final[Unix] = <platformdirs.unix.Unix object>

A pre-constructed PlatformDirs object for Torii

torii.util.directories.get_sys_cache(mkdir: bool = True) Path

Returns the path to the system-wide cache directory.

If the TORII_CACHE_DIR environment variable is set, that is used instead.

Parameters:

mkdir (bool) – Create the target directory if it doesn’t exist.

Return type:

Path

Returns:

Path – The path to the appropriate system cache directory if it exists, otherwise the user cache dir.

Raises:

PermissionError – When the system directory doesn’t exist, and we fall back to the user directory, if it doesn’t exist and we can’t create it.

torii.util.directories.get_sys_config(mkdir: bool = True) Path

Returns the path to the system-wide configuration directory.

If the TORII_CONFIG_DIR environment variable is set, that is used instead.

Parameters:

mkdir (bool) – Create the target directory if it doesn’t exist.

Return type:

Path

Returns:

Path – The path to the appropriate system configuration directory if it exists, otherwise the user config dir.

Raises:

PermissionError – When the system directory doesn’t exist, and we fall back to the user directory, if it doesn’t exist and we can’t create it.

torii.util.directories.get_sys_data(mkdir: bool = True) Path

Returns the path to the system-wide data directory.

If the TORII_DATA_DIR environment variable is set, that is used instead.

Parameters:

mkdir (bool) – Create the target directory if it doesn’t exist.

Return type:

Path

Returns:

Path – The path to the appropriate system data directory if it exists, otherwise the user data dir.

Raises:

PermissionError – When the system directory doesn’t exist, and we fall back to the user directory, if it doesn’t exist and we can’t create it.

torii.util.directories.get_sys_runtime(mkdir: bool = True) Path

Returns the path to the system-wide runtime directory.

If the TORII_RUNTIME_DIR environment variable is set, that is used instead.

Parameters:

mkdir (bool) – Create the target directory if it doesn’t exist.

Return type:

Path

Returns:

Path – The path to the appropriate system runtime directory if it exists, other wise the user runtime dir.

Raises:

PermissionError – When the system directory doesn’t exist, and we fall back to the user directory, if it doesn’t exist and we can’t create it.

torii.util.directories.get_user_cache(mkdir: bool = True) Path

Returns the path to the user-specific cache directory.

If the TORII_CACHE_DIR environment variable is set, that is used instead.

Parameters:

mkdir (bool) – Create the target directory if it doesn’t exist.

Return type:

Path

Returns:

Path – The path to the appropriate user cache directory.

Raises:

PermissionError – If we are unable to create the target directory if it doesn’t exist.

torii.util.directories.get_user_config(mkdir: bool = True) Path

Returns the path to the user-specific configuration directory.

If the TORII_CONFIG_DIR environment variable is set, that is used instead.

Parameters:

mkdir (bool) – Create the target directory if it doesn’t exist.

Return type:

Path

Returns:

Path – The path to the appropriate user configuration directory.

Raises:

PermissionError – If we are unable to create the target directory if it doesn’t exist.

torii.util.directories.get_user_data(mkdir: bool = True) Path

Returns the path to the user-specific data directory.

If the TORII_DATA_DIR environment variable is set, that is used instead.

Parameters:

mkdir (bool) – Create the target directory if it doesn’t exist.

Return type:

Path

Returns:

Path – The path to the appropriate user data directory.

Raises:

PermissionError – If we are unable to create the target directory if it doesn’t exist.

torii.util.directories.get_user_runtime(mkdir: bool = True) Path

Returns the path to the user-specific runtime directory.

If the TORII_RUNTIME_DIR environment variable is set, that is used instead.

Parameters:

mkdir (bool) – Create the target directory if it doesn’t exist.

Return type:

Path

Returns:

Path – The path to the appropriate user runtime directory.

Raises:

PermissionError – If we are unable to create the target directory if it doesn’t exist.

torii.util.directories.get_user_state(mkdir: bool = True) Path

Returns the path to the user-specific state directory.

If the TORII_STATE_DIR environment variable is set, that is used instead.

Parameters:

mkdir (bool) – Create the target directory if it doesn’t exist.

Return type:

Path

Returns:

Path – The path to the appropriate user state directory.

Raises:

PermissionError – If we are unable to create the target directory if it doesn’t exist.