Documentation
¶
Index ¶
- Variables
- func AtomicWrite(path string, data []byte) error
- func CopyFile(src, dst string) error
- func EnsureDir(path string) error
- func EnsureParentDir(path string) error
- func ExpandPageRanges(ranges []PageRange) []int
- func FileExists(path string) bool
- func FormatError(err error) string
- func FormatFileSize(bytes int64) string
- func FormatPageRanges(pages []int) string
- func GenerateOutputFilename(input, suffix string) string
- func GetFileSize(path string) (int64, error)
- func IsDir(path string) bool
- func IsFileNotFound(err error) bool
- func IsPasswordRequired(err error) bool
- func ParseAndExpandPages(input string) ([]int, error)
- func ValidatePDFFile(path string) error
- func ValidatePDFFiles(paths []string) error
- func ValidatePageNumbers(pages []int, totalPages int) error
- func WrapError(operation string, file string, err error) error
- type PDFError
- type PageRange
Constants ¶
This section is empty.
Variables ¶
var ( ErrFileNotFound = errors.New("file not found") ErrNotPDF = errors.New("not a valid PDF file") ErrInvalidPages = errors.New("invalid page specification") ErrPasswordRequired = errors.New("password required") ErrWrongPassword = errors.New("incorrect password") ErrCorruptPDF = errors.New("PDF file is corrupted") ErrOutputExists = errors.New("output file already exists") )
Common error types
Functions ¶
func AtomicWrite ¶
AtomicWrite writes data to a file atomically by writing to a temp file first
func EnsureParentDir ¶
EnsureParentDir creates the parent directory of a file path if it doesn't exist
func ExpandPageRanges ¶
ExpandPageRanges expands a slice of PageRange to individual page numbers
func FormatError ¶
FormatError formats an error for display to the user
func FormatFileSize ¶
FormatFileSize formats a file size in bytes to a human-readable string
func FormatPageRanges ¶
FormatPageRanges converts a slice of page numbers back to a compact range string
func GenerateOutputFilename ¶
GenerateOutputFilename generates an output filename based on the input and a suffix
func GetFileSize ¶
GetFileSize returns the size of a file in bytes
func IsFileNotFound ¶
IsFileNotFound checks if an error is a file not found error
func IsPasswordRequired ¶
IsPasswordRequired checks if an error indicates a password is required
func ParseAndExpandPages ¶
ParseAndExpandPages parses a page range string and returns individual page numbers
func ValidatePDFFile ¶
ValidatePDFFile checks if a file exists and has a .pdf extension
func ValidatePDFFiles ¶
ValidatePDFFiles validates multiple PDF files
func ValidatePageNumbers ¶
ValidatePageNumbers checks if all page numbers are within the valid range
Types ¶
type PDFError ¶
PDFError represents a user-friendly error for PDF operations
func NewPDFError ¶
NewPDFError creates a new PDFError