fileutil

package
v1.0.126 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package fileutil provides durable filesystem helpers shared by package main and internal/* packages (ADR-0003). It has no dependency on the rest of Culvert (stdlib only).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AtomicWrite

func AtomicWrite(path string, data []byte, perm os.FileMode) error

AtomicWrite writes data to path atomically: it writes to a unique temp file in the same directory, chmods, fsyncs the file, renames over the target, and best-effort fsyncs the parent directory. A crash mid-write never leaves a partial or corrupt target file. Moved verbatim from package main's atomicWriteFile (ADR-0003); behaviour is unchanged.

Types

type RotatingFile added in v1.0.16

type RotatingFile struct {
	// contains filtered or unexported fields
}

RotatingFile wraps a log file and rotates it when it exceeds maxBytes.

func NewRotatingFile added in v1.0.16

func NewRotatingFile(path string, maxMB int) (*RotatingFile, error)

NewRotatingFile opens path for append and returns a writer that rotates the file to path+".1" when it exceeds maxMB (<=0 falls back to 50 MB).

func (*RotatingFile) Close added in v1.0.16

func (r *RotatingFile) Close() error

Close closes the underlying file.

func (*RotatingFile) Write added in v1.0.16

func (r *RotatingFile) Write(p []byte) (int, error)

Write appends p, rotating first when the size cap would be exceeded.

Jump to

Keyboard shortcuts

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