fsutil

package
v0.0.0-...-04b9a38 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: MIT Imports: 20 Imported by: 0 modules, 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 GetAlias

func GetAlias(inputPaths []string, c *ListFilesConfig, virtualPath string) string

GetAlias returns the display alias for a file. It checks FileAliases glob patterns first, then falls back to the path relative to the first matching input path.

Types

type FileHandle

type FileHandle struct {
	File                VirtualFile
	Alias               []byte
	AliasForBlock       []byte
	AliasForLine        []byte
	Size                int64                 // Size of the file in bytes
	BytesRead           int64                 // Number of bytes read from the file
	Done                bool                  // Whether the file has been fully read
	Buffer              *container.RingBuffer // Buffer for reading the file
	LineTimestampParsed bool                  // Whether the timestamp for the current line has been parsed
	LineTimestamp       logtime.Timestamp     // The timestamp for the current line
	LineTimestampStart  int                   // Byte offset where the timestamp section starts (including leading delimiters)
	LineTimestampEnd    int                   // Byte offset where the timestamp section ends (including trailing delimiters)
	LineLevel           byte                  // Detected log level for the current line (loglevel.Level)
	LineLevelStart      int                   // Byte offset where the level token starts
	LineLevelEnd        int                   // Byte offset where the level token ends
	BlockTimestamp      logtime.Timestamp     // The timestamp for the current block, i.e. the last non-zero timestamp
	Metrics             *metrics.MetricsTree
	MergeMetrics        *metrics.MergeMetrics
	// contains filtered or unexported fields
}

func ListFiles

func ListFiles(inputPaths []string, c *ListFilesConfig, m *metrics.ListFilesMetrics, totalBufferSize int, minBufferSizePerFile int, logFile *WritableFile) (files []*FileHandle, err error)

ListFiles discovers files from inputPaths (files or directories), applies ignore patterns, transparently opens archives, and returns a FileHandle per discovered file.

func NewFileHandle

func NewFileHandle(file VirtualFile, alias string, bufferSize int) (fh *FileHandle, err error)

NewFileHandle creates a FileHandle wrapping the given VirtualFile with its own read buffer and per-file metrics.

func (*FileHandle) Close

func (r *FileHandle) Close() error

Close closes the underlying VirtualFile.

func (*FileHandle) FillBuffer

func (r *FileHandle) FillBuffer() error

FillBuffer reads data from the underlying file into the ring buffer.

func (*FileHandle) GetBytesRead

func (r *FileHandle) GetBytesRead() int64

func (*FileHandle) GetFileSize

func (r *FileHandle) GetFileSize() int64

func (*FileHandle) IsDone

func (r *FileHandle) IsDone() bool

func (*FileHandle) SkipLine

func (r *FileHandle) SkipLine() (bytesCount int, eolLength int, err error)

SkipLine advances past the current line in the buffer without writing it, returning the number of bytes skipped and the EOL length.

func (*FileHandle) WriteLine

func (r *FileHandle) WriteLine(m *metrics.MergeMetrics, writer *bufio.Writer) error

WriteLine writes the current line from the buffer to the writer, ensuring it ends with a newline. Updates byte and line-length metrics.

type ListFilesConfig

type ListFilesConfig struct {
	IgnoreFile     string            `yaml:"IgnoreFile"`
	IgnorePatterns []string          `yaml:"IgnorePatterns"`
	IgnoreArchives bool              `yaml:"IgnoreArchives"`
	FollowSymlinks bool              `yaml:"FollowSymlinks"`
	FileAliases    map[string]string `yaml:"FileAliases"`
}

type Matcher

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

func NewMatcher

func NewMatcher(patterns []string) *Matcher

NewMatcher creates a Matcher from gitignore-style glob patterns. Blank lines and lines starting with # are skipped. Patterns prefixed with ! are negations. A backslash before # or ! escapes the special meaning. Trailing spaces are ignored unless escaped with backslash (\ ).

func (*Matcher) ShouldInclude

func (m *Matcher) ShouldInclude(filePath string) (included bool)

ShouldInclude returns whether filePath passes the filter rules. Rules are evaluated in order; the last matching rule wins. Default is include.

type OsFile

type OsFile struct {
	F *os.File
}

OsFile wraps a standard *os.File as a VirtualFile.

func (*OsFile) Close

func (f *OsFile) Close() error

func (*OsFile) Name

func (f *OsFile) Name() string

func (*OsFile) Read

func (f *OsFile) Read(p []byte) (int, error)

func (*OsFile) Size

func (f *OsFile) Size() int64

type VirtualFile

type VirtualFile interface {
	io.ReadCloser
	Name() string
	Size() int64
}

VirtualFile abstracts a readable file, supporting transparent decompression.

type WritableFile

type WritableFile struct {
	Path string
	File *os.File
}

func (*WritableFile) Close

func (f *WritableFile) Close() error

func (*WritableFile) Initialize

func (f *WritableFile) Initialize() error

Initialize creates the file at Path (and its parent directories). If Path is empty, the existing File handle (e.g. os.Stdout) is left unchanged.

func (*WritableFile) MarshalYAML

func (f *WritableFile) MarshalYAML() (interface{}, error)

func (*WritableFile) UnmarshalYAML

func (f *WritableFile) UnmarshalYAML(value *yaml.Node) error

func (*WritableFile) Write

func (f *WritableFile) Write(p []byte) (n int, err error)

Jump to

Keyboard shortcuts

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