file

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2025 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrFileNotFound is returned when a file does not exist
	ErrFileNotFound = errors.New("file not found")

	// ErrContentChanged is returned when the file content has changed since it was last read
	ErrContentChanged = errors.New("file content has changed")

	// ErrInvalidRange is returned when an invalid range is specified
	ErrInvalidRange = errors.New("invalid range specified")

	// ErrInvalidEncoding is returned when an unsupported encoding is specified
	ErrInvalidEncoding = errors.New("invalid encoding specified")
)

Functions

This section is empty.

Types

type LineRange

type LineRange struct {
	Start int
	End   int
}

LineRange represents a range of lines in a file

type Service

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

Service provides file operation methods

func NewService

func NewService(defaultEncoding string, autoDetect bool) *Service

NewService creates a new file service

func (*Service) AppendLines

func (s *Service) AppendLines(filePath string, encName string, lines []string) error

AppendLines appends lines to a file

func (*Service) DeleteLines

func (s *Service) DeleteLines(filePath string, oldHash string, encName string, lineNumbers []int) error

DeleteLines deletes lines from a file with hash validation

func (*Service) DetectEncoding

func (s *Service) DetectEncoding(filePath string) (encoding.Encoding, string, error)

DetectEncoding attempts to detect the encoding of a file

func (*Service) EditLines

func (s *Service) EditLines(filePath string, oldHash string, encName string, lineEdits map[int]string) error

EditLines edits lines in a file with hash validation

func (*Service) InsertLines

func (s *Service) InsertLines(filePath string, oldHash string, encName string, position int, newLines []string) error

InsertLines inserts lines at a specific position with hash validation

func (*Service) ReadLines

func (s *Service) ReadLines(filePath string, encName string, ranges ...LineRange) ([]string, string, error)

ReadLines reads lines from a file with optional range specification

Jump to

Keyboard shortcuts

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