Documentation
¶
Overview ¶
Package fileio provides file I/O operations and stdio handling for pdf-cli.
Index ¶
- Constants
- 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 FileExists(path string) bool
- func FormatFileSize(bytes int64) string
- func GenerateOutputFilename(input, suffix string) string
- func GetFileSize(path string) (int64, error)
- func IsDir(path string) bool
- func IsImageFile(path string) bool
- func IsStdinInput(path string) bool
- func IsStdinPiped() bool
- func ReadFromStdin() (path string, cleanup func(), err error)
- func ResolveInputPath(input string) (path string, cleanup func(), err error)
- func ValidatePDFFile(path string) error
- func ValidatePDFFiles(paths []string) error
- func WriteToStdout(path string) error
Constants ¶
const StdinIndicator = "-"
StdinIndicator is the conventional indicator for stdin input.
Variables ¶
var SupportedImageExtensions = []string{".png", ".jpg", ".jpeg", ".tif", ".tiff"}
SupportedImageExtensions contains all supported image file extensions.
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 FormatFileSize ¶
FormatFileSize formats a file size in bytes to a human-readable 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 IsImageFile ¶
IsImageFile checks if a file has a supported image extension.
func IsStdinInput ¶
IsStdinInput returns true if the input path indicates stdin.
func IsStdinPiped ¶
func IsStdinPiped() bool
IsStdinPiped returns true if stdin has data piped to it (not a terminal).
func ReadFromStdin ¶
ReadFromStdin reads stdin to a temporary file and returns the path and cleanup function. The caller is responsible for calling the cleanup function when done.
func ResolveInputPath ¶
ResolveInputPath resolves an input path, handling stdin indicator. Returns the actual path to use and a cleanup function. If the input is not stdin, cleanup is a no-op.
func ValidatePDFFile ¶
ValidatePDFFile checks if a file exists and has a .pdf extension
func ValidatePDFFiles ¶
ValidatePDFFiles validates multiple PDF files in parallel
func WriteToStdout ¶
WriteToStdout writes a file's contents to stdout.
Types ¶
This section is empty.