util

package
v1.0.112 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 22, 2026 License: LGPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BackupAndReplace

func BackupAndReplace(src, dest string) error

BackupAndReplace backs up a file and replaces it.

func CopyFile

func CopyFile(src, dest string) error

CopyFile is a helper function to copy a file.

func DecompressChunkSlice added in v1.0.112

func DecompressChunkSlice(chunk []byte, expectedSize uint32) ([]byte, error)

DecompressChunkSlice decompresses a single Steam Pipe chunk slice (up to 1MB) matching any Steam Pipe stream format.

func DecompressVSZaData added in v1.0.112

func DecompressVSZaData(data []byte) ([]byte, error)

DecompressVSZaData decompresses a stream of 1MB (1,048,576 byte) Steam Pipe chunk slices using any supported stream format. Files downloaded directly as raw Steam depot chunks are stored as concatenated 1MB container frames.

func DecompressVSZaFile added in v1.0.112

func DecompressVSZaFile(filePath string) (bool, error)

DecompressVSZaFile decompresses a compressed Steam depot file on disk in place. Returns true if the file was compressed and decompressed successfully.

func DecompressVSZaInDir added in v1.0.112

func DecompressVSZaInDir(dirPath string) (int, error)

DecompressVSZaInDir walks dirPath recursively and decompresses any VSZa-compressed files in place. Returns the total number of files decompressed.

func DownloadAndExtract

func DownloadAndExtract(ctx context.Context, url, destDir, format string) error

DownloadAndExtract downloads a file and extracts it.

func ExpandPath added in v1.0.108

func ExpandPath(path string) string

ExpandPath resolves tilde (~) and relative paths against home directory.

func ExtractSuggestedFixes added in v1.0.107

func ExtractSuggestedFixes(err error) []string

ExtractSuggestedFixes returns suggested fixes from a FixableError if present.

func FileExists added in v0.4.0

func FileExists(path string) bool

FileExists checks if a file exists on disk.

func GetHash

func GetHash(filePath string) (string, error)

GetHash returns the SHA1 hash of a file.

func GetSHA1Hash added in v1.0.107

func GetSHA1Hash(filePath string) (string, error)

GetSHA1Hash returns the SHA1 hash of a file.

func IsEncryptedBase64Path added in v1.0.109

func IsEncryptedBase64Path(p string) bool

IsEncryptedBase64Path checks if a filename or path contains raw un-decrypted AES base64 output.

func IsSteamChunkCompressed added in v1.0.112

func IsSteamChunkCompressed(data []byte) bool

IsSteamChunkCompressed checks if data starts with any known Steam Pipe chunk container header. Supported stream formats: 1. "VSZa": Valve Zstandard chunk container (magic 0x56 0x53 0x5A 0x61) 2. "VZ" / "VZa": Valve LZMA chunk container (magic 0x56 0x5A) 3. "PK\x03\x04": Zip archive chunk (magic 0x50 0x4B 0x03 0x04) 4. 0x28B52FFD: Raw Zstandard frame

func IsVSZaCompressed added in v1.0.112

func IsVSZaCompressed(data []byte) bool

IsVSZaCompressed checks if data starts with Valve's VSZa zstd container header. Valve's VSZa chunk container format uses: - 4 bytes magic: "VSZa" (0x56 0x53 0x5A 0x61) - 4 bytes header metadata: 32-bit CRC32 checksum / chunk metadata - Payload: Zstandard (zstd) compressed frame starting at offset 8

func RunCmd

func RunCmd(name string, args ...string) ([]byte, error)

runCmd executes a command and returns its output or an error.

func SanitizeFilename added in v1.0.107

func SanitizeFilename(name string) string

SanitizeFilename replaces illegal filesystem characters with dashes to return a clean folder name.

func SanitizeInstallDir added in v1.0.108

func SanitizeInstallDir(title string) string

SanitizeInstallDir converts a game title into a clean, 1:1 Steam-style installdir folder name. It removes trademark/registered symbols (™, ®, ©), removes illegal OS path characters, and normalizes whitespace while preserving standard folder readability.

func WithFixes added in v1.0.107

func WithFixes(err error, fixes ...string) error

WithFixes wraps an error with actionable diagnostic fix suggestions.

Types

type FixableError added in v1.0.107

type FixableError interface {
	error
	SuggestedFixes() []string
}

FixableError is an error interface that carries suggested diagnostic fix actions.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL