Documentation
¶
Index ¶
- Constants
- func DetectBinaryFile(path string) error
- func IsBinaryFileError(err error) bool
- func ReadFileLines(path string) ([]string, error)
- func ValidateFilePath(path string) error
- func ValidateOutputPath(path string) error
- func WriteOutputFile(path string, content string) error
- type BinaryFileError
- type FileReader
Constants ¶
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 ¶
DetectBinaryFile is a standalone function for binary detection Useful for quick binary file checks
func IsBinaryFileError ¶
IsBinaryFileError checks if the error is a binary file error
func ReadFileLines ¶
ReadFileLines is a standalone function for reading file lines Useful for compatibility with existing code
func ValidateFilePath ¶
ValidateFilePath checks if a file path is valid for reading
func ValidateOutputPath ¶
ValidateOutputPath checks if an output path is valid for writing
func WriteOutputFile ¶
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