fsutil

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package fsutil holds small filesystem helpers shared across commands.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExistingPerm

func ExistingPerm(path string, def fs.FileMode) fs.FileMode

ExistingPerm returns path's permission bits, or def when it cannot be stat'd. Use with WriteAtomic to keep an existing file's mode.

func OpenJSONL

func OpenJSONL(path string, replay func([]byte)) (*os.File, error)

OpenJSONL replays the append-only log at path line by line into replay, then returns it open for appending. A torn trailing line (crash mid-write) is handed to replay like any other (callers skip lines that don't decode) and then terminated with '\n', so the next record starts on its own line instead of being glued onto — and lost with — the torn one.

func RestrictToOwner

func RestrictToOwner(string) error

RestrictToOwner is a no-op here: the 0600 mode the caller creates files with already is owner-only. (Windows replaces the DACL.)

func VerifyPrivate

func VerifyPrivate(path string) error

VerifyPrivate reports whether group and other have no access to path.

func WriteAtomic

func WriteAtomic(path string, data []byte, perm fs.FileMode) (err error)

WriteAtomic writes data to path so a reader sees either the old or the new content, never a partial file: temp file in the same directory, fsync, chmod perm, rename, fsync the directory. The directory must exist.

Types

This section is empty.

Jump to

Keyboard shortcuts

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