Documentation
¶
Overview ¶
Package fsx provides path safety, hashing and copy primitives.
Index ¶
- Constants
- Variables
- func BlockHash(path string) (string, bool)
- func CopyFile(src, dst string, overwrite bool) error
- func DiffFiles(oldPath, newPath, oldLabel, newLabel string, limit int) string
- func Exists(path string) bool
- func HashFile(path string) (string, error)
- func HashTree(root string, files []string) (string, error)
- func HostText(path string) (string, bool)
- func IsShared(rel string) bool
- func ListFiles(root string) ([]string, error)
- func Merge(hostText, gttText string) string
- func ReadJSON(path string, v any) error
- func SafeJoin(root, rel string) (string, error)
- func StripOrRemove(path string) error
- func WriteJSON(path string, v any) error
- func WriteMerged(path, gttText string) error
Constants ¶
SharedFile is the one core file a host project may already have: AGENTS.md is an open convention other tools write too. GTT never takes it over and never refuses to install because of it (Canon 3.0 §28): it keeps its contract inside a delimited block of the host's file and touches only that block - on install, update, clean, export and rollback alike.
Variables ¶
var IgnoredDirs = map[string]bool{".git": true, "__pycache__": true}
IgnoredDirs are never hashed, copied or exported as package content.
Functions ¶
func BlockHash ¶ added in v1.8.0
BlockHash is the hash of GTT's block in a shared file, comparable with the ledger's hash of the package file; ok is false when the file has no block.
func CopyFile ¶
CopyFile copies src to dst preserving the mode; it creates parent directories and refuses to overwrite unless overwrite is true.
func DiffFiles ¶ added in v1.1.0
DiffFiles returns a compact line diff from the file at oldPath to the file at newPath, in unified style with two lines of context and at most limit lines of output. Binary or very large files are summarized, not printed.
func HashTree ¶
HashTree returns one sha256 over the sorted (path, content hash) pairs of the given files under root.
func HostText ¶ added in v1.8.0
HostText is the file without GTT's block, and whether anything of the host remains (false: the file is entirely GTT's and may be removed whole).
func IsShared ¶ added in v1.8.0
IsShared reports whether a core path is the shared instruction file.
func ListFiles ¶
ListFiles returns every regular file under root as slash-separated paths relative to root, sorted. Symlinks are reported through the error: a package or an export source containing one that escapes root is unsafe.
func Merge ¶ added in v1.8.0
Merge places GTT's contract in the host's file as one delimited block, replacing a previous block and keeping every host line.
func SafeJoin ¶
SafeJoin joins rel under root and rejects absolute or rooted paths, traversal and any existing symlink component that resolves outside root.
func StripOrRemove ¶ added in v1.8.0
StripOrRemove takes GTT out of a shared file: the block goes, the host's lines stay; a file that is only GTT's contract is removed. A file with no GTT block that is not GTT's contract is the host's alone and is left as is (an init interrupted before the merge must not cost the host its file).
func WriteMerged ¶ added in v1.8.0
WriteMerged writes GTT's contract into the host's existing file.
Types ¶
This section is empty.