zos

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Copy added in v0.9.9

func Copy(from, to string) (err error)

Copy a file from one location to another

func CopyTemp added in v0.9.9

func CopyTemp(from, to string) (err error)

Copy a file from one location to another using a temp file

func CreateWith added in v0.3.0

func CreateWith(path string, handler FileHandler) (err error)

Create a file and use it inside a closure. Will automatically close the file after the closure completes and remove the corrupt file if an error is thrown.

func CreateWithTemp added in v0.3.0

func CreateWithTemp(path string, handler FileHandler) error

Like CreateWith, but will create a temporary file and rename it to the final path once the file has been written successfully. If an error occurs, the temp file will be removed.

func Exists

func Exists(path string) bool

Determine if a path exists or not

func HasPrefix added in v0.11.6

func HasPrefix(path string, prefix []byte) (bool, error)

Determine if a file starts with a given prefix

func IsDir added in v0.8.1

func IsDir(path string) bool

Returns true if a path exists and is a directory. It still returns false even if the path doesn't exist.

func OpenFirst added in v0.9.6

func OpenFirst(paths ...string) (f *os.File, err error)

Open the first existing path in a list of paths

func ReadLines added in v0.9.2

func ReadLines(f io.Reader) (lines []string, err error)

Read all lines from an open text file into a slice

func ReadLinesFromFile added in v0.9.6

func ReadLinesFromFile(path string) (lines []string, err error)

Read all lines from a text file into a slice

Types

type FileHandler added in v0.3.0

type FileHandler = func(f *os.File) error

Jump to

Keyboard shortcuts

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