io

package
v1.9.6 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// BufferSize defines the buffer size for reading files (1MB)
	BufferSize = 1024 * 1024
	// BinaryDetectionSize defines how many bytes to check for binary content
	BinaryDetectionSize = 512
)

Variables

This section is empty.

Functions

func DetectBinaryFile

func DetectBinaryFile(path string) error

DetectBinaryFile is a standalone function for binary detection Useful for quick binary file checks

func IsBinaryFileError

func IsBinaryFileError(err error) bool

IsBinaryFileError checks if the error is a binary file error

func ReadFileLines

func ReadFileLines(path string) ([]string, error)

ReadFileLines is a standalone function for reading file lines Useful for compatibility with existing code

func ValidateFilePath

func ValidateFilePath(path string) error

ValidateFilePath checks if a file path is valid for reading

func ValidateOutputPath

func ValidateOutputPath(path string) error

ValidateOutputPath checks if an output path is valid for writing

func WriteOutputFile

func WriteOutputFile(path string, content string) error

WriteOutputFile writes content to the specified path or stdout if path is "-"

Types

type BinaryFileError

type BinaryFileError struct {
	Message string
}

BinaryFileError represents an error when a binary file is detected

func (*BinaryFileError) Error

func (e *BinaryFileError) Error() string

type FileReader

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

FileReader provides unified file reading capabilities

func NewFileReader

func NewFileReader() *FileReader

NewFileReader creates a new file reader with binary detection enabled by default

func (*FileReader) DetectBinaryContent

func (fr *FileReader) DetectBinaryContent(reader io.Reader) error

DetectBinaryContent checks if the reader contains binary content by looking for null bytes

func (*FileReader) ReadInputFile

func (fr *FileReader) ReadInputFile(path string) (io.Reader, error)

ReadInputFile reads from the specified path or stdin if path is "-" Returns an io.Reader for the content and any error encountered

func (*FileReader) ReadInputLines

func (fr *FileReader) ReadInputLines(path string) ([]string, error)

ReadInputLines reads lines from the specified path or stdin if path is "-" Returns a slice of lines and any error encountered

func (*FileReader) SetBinaryDetection

func (fr *FileReader) SetBinaryDetection(enabled bool)

SetBinaryDetection enables or disables binary file detection

Jump to

Keyboard shortcuts

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