Skip to main content

Module guard

Module guard 

Source
Expand description

Game-running guard and transaction logging.

Before launch and before each destructive operation, check whether Subnautica 2 is running โ€” the game holds file locks on .sav files while active.

Constantsยง

MAX_LOG_LINES ๐Ÿ”’
Maximum lines before rotation.

Functionsยง

_game_running_linux ๐Ÿ”’
Check if Subnautica 2 is running via pgrep (Linux). Dormant.
available_space
Estimate free space on the volume containing path in bytes. Returns None on platforms or filesystems where we canโ€™t determine this.
exe_dir ๐Ÿ”’
Return the directory containing the running executable.
game_running
Check if Subnautica 2 is currently running (Linux).
is_network_path
Check whether a path looks like a network/UNC path โ€” for warning purposes. Matches paths starting with \\ (Windows) or // (Linux).
log_action
Append a timestamped log entry to transaction.log.
log_path
Path to transaction.log inside the logs/ directory under the platform config root. All timestamped actions are appended here for audit trail purposes.
migrate_old_log
Migrate the old transaction.log (next to the binary) into the new logs/ directory. Appends old entries to the new file, then renames the old file to .migrated so it wonโ€™t be migrated again. Returns true if an old log was found and handled.
sanitize_path
Truncate a filesystem path to start at Subnautica2/ or Subnautica2\, stripping the user-specific prefix for privacy-safe logging.