fileio

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package fileio provides file I/O operations and stdio handling for pdf-cli.

Index

Constants

View Source
const StdinIndicator = "-"

StdinIndicator is the conventional indicator for stdin input.

Variables

View Source
var SupportedImageExtensions = []string{".png", ".jpg", ".jpeg", ".tif", ".tiff"}

SupportedImageExtensions contains all supported image file extensions.

Functions

func AtomicWrite

func AtomicWrite(path string, data []byte) error

AtomicWrite writes data to a file atomically by writing to a temp file first

func CopyFile

func CopyFile(src, dst string) error

CopyFile copies a file from src to dst

func EnsureDir

func EnsureDir(path string) error

EnsureDir creates a directory if it doesn't exist

func EnsureParentDir

func EnsureParentDir(path string) error

EnsureParentDir creates the parent directory of a file path if it doesn't exist

func FileExists

func FileExists(path string) bool

FileExists checks if a file exists

func FormatFileSize

func FormatFileSize(bytes int64) string

FormatFileSize formats a file size in bytes to a human-readable string

func GenerateOutputFilename

func GenerateOutputFilename(input, suffix string) string

GenerateOutputFilename generates an output filename based on the input and a suffix

func GetFileSize

func GetFileSize(path string) (int64, error)

GetFileSize returns the size of a file in bytes

func IsDir

func IsDir(path string) bool

IsDir checks if a path is a directory

func IsImageFile

func IsImageFile(path string) bool

IsImageFile checks if a file has a supported image extension.

func IsStdinInput

func IsStdinInput(path string) bool

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

func ReadFromStdin() (path string, cleanup func(), err error)

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

func ResolveInputPath(input string) (path string, cleanup func(), err error)

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

func ValidatePDFFile(path string) error

ValidatePDFFile checks if a file exists and has a .pdf extension

func ValidatePDFFiles

func ValidatePDFFiles(paths []string) error

ValidatePDFFiles validates multiple PDF files in parallel

func WriteToStdout

func WriteToStdout(path string) error

WriteToStdout writes a file's contents to stdout.

Types

This section is empty.

Jump to

Keyboard shortcuts

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