fs

package
v1.261112.1 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2026 License: MPL-2.0 Imports: 7 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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