fsutil

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package fsutil holds the filesystem helpers shared by the fetchers, the renderer and the command layer.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyDir

func CopyDir(src, dst string) error

CopyDir recursively copies src into dst.

func CopyFile

func CopyFile(src, dst string) error

CopyFile copies src to dst, preserving the executable bit.

func IsEmptyDir

func IsEmptyDir(path string) (bool, error)

IsEmptyDir reports whether path is an empty directory. A missing directory counts as empty, which is what `rig new` into a fresh path wants.

func MoveDir

func MoveDir(src, dst string) error

MoveDir copies src into dst and removes src.

This is a copy rather than a rename because the staging directory lives in the system temp dir, which is routinely a different filesystem — often a tmpfs — from the user's project. A rename-only implementation would fail exactly when someone first tried the tool. The copy is cheap in practice: staging only ever holds generated files, since hooks run after the move.

func SafeJoin

func SafeJoin(root, rel string) (string, error)

SafeJoin joins rel onto root and guarantees the result stays inside root. Every write rig performs goes through this: template-rendered paths and blueprint-declared paths are both attacker-controlled if you did not write the blueprint yourself, so containment cannot be left to convention.

func WriteFile

func WriteFile(path string, data []byte, mode os.FileMode) error

WriteFile writes data to path, creating parent directories.

Types

This section is empty.

Jump to

Keyboard shortcuts

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