fs

package
v0.260806.1 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2026 License: MPL-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnsureDir

func EnsureDir(path string) error

EnsureDir creates a directory if it doesn't exist

func ExpandConfigDir

func ExpandConfigDir(path string) (string, error)

ExpandConfigDir expands ~ to user home directory and returns absolute path

func GetUserCachePath

func GetUserCachePath(appName string) (string, error)

GetUserCachePath returns the platform-specific user cache directory This follows the conventions of each operating system: - Linux/Unix: ~/.cache - macOS: ~/Library/Caches - Windows: %LOCALAPPDATA%

func GetUserConfigPath

func GetUserConfigPath(appName string) (string, error)

GetUserConfigPath returns the platform-specific user config directory This follows the conventions of each operating system: - Linux/Unix: ~/.config - macOS: ~/Library/Application Support - Windows: %APPDATA%

func GetUserPath

func GetUserPath() (string, error)

GetUserPath returns the user's home directory path across all platforms It provides a consistent way to get the user directory regardless of the operating system

func SafeFileKey added in v0.260801.1

func SafeFileKey(id string) string

SafeFileKey maps an externally-supplied identifier to a basename that is safe to join into a directory path.

The identifiers this exists for do not come from us: IM platforms mint chat ids containing '@' or '/' (WhatsApp JIDs, Feishu ids), and a session id can be whatever a user typed after /resume. Joining one into a path unchecked is a directory traversal on both read and write — "../../etc/passwd" resolves outside the store.

Identifiers that are already safe (ASCII letters, digits, '_' and '-') pass through verbatim, so numeric chat ids and UUID session ids stay readable on disk and existing files keep resolving with no migration. Anything else is replaced by a SHA-256 digest: stable, collision-free in practice, and unable to escape the directory.

Note '.' is deliberately unsafe, so "." and ".." can never survive.

Types

This section is empty.

Jump to

Keyboard shortcuts

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