Documentation
¶
Overview ¶
Package fileops provides file system operations for token counting, including directory traversal with .gitignore support and binary detection.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AggregateFileContents ¶
AggregateFileContents reads all files and returns combined content. Pre-allocates the result buffer based on file sizes to minimize allocations.
func IsBinaryContent ¶ added in v0.5.1
IsBinaryContent applies the same extension and null-byte prefix rules as IsBinaryFile to bytes that have already been read by a caller.
func IsBinaryFile ¶
func IsBinaryFile(path string, collectors ...BinaryStatsCollector) (bool, error)
IsBinaryFile checks if a file is likely binary.
Types ¶
type BinaryStatsCollector ¶ added in v0.5.1
type BinaryStatsCollector interface {
RecordBinarySniffOpen()
RecordBinarySniffBytes(int64)
RecordValidationReadDuration(time.Duration)
}
BinaryStatsCollector receives optional instrumentation from binary detection. It is deliberately small so the normal path can pass nil without creating a dependency on the tokenizer package.
type WalkResult ¶
WalkResult contains information about walked files.
func WalkDirectory ¶
func WalkDirectory(ctx context.Context, rootPath string, collectors ...WalkStatsCollector) (*WalkResult, error)
WalkDirectory recursively walks a directory, respecting .gitignore files and filtering out binary files.
type WalkStatsCollector ¶ added in v0.5.1
type WalkStatsCollector interface {
BinaryStatsCollector
RecordEntryVisited()
RecordEligibleFile()
RecordWalkDuration(time.Duration)
}
WalkStatsCollector receives optional instrumentation from directory walking.