file

package
v0.0.0-...-3fb1d06 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package file provides various helpers for working with files on an OS filesystem.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotDir = errors.New("not a directory")

ErrNotDir indicates a path was not a directory.

View Source
var ErrNotRegularFile = errors.New("not a regular file")

ErrNotRegularFile indicates a path was not a regular file. For example, this could mean it was a symlink.

Functions

func CopyDirContents

func CopyDirContents(src, dst string) error

CopyDirContents copies all contents from the directory src to the directory dst. Only regular files and directories will be copied. If src or dst is not a directory, and error will be returned. If dst does not exists, it will be created.

func CopyFile

func CopyFile(src, dst string) error

CopyFile copies the regular file located at src to dst. Any intermediate directories in dst that do not exists will be created. If src is not a regular file an error will be returned.

func DirLen

func DirLen(path string) (int, error)

DirLen returns the number of items in the directory located at path.

func DirSize

func DirSize(path string) (int64, error)

DirSize returns the size of the directory located at path.

func Download

func Download(dst string, r io.Reader) (int64, error)

Download creates or replaces a file at dst by reading from r.

func Exists

func Exists(path string) bool

Exists checks if a file or directory exists at path.

func Untar

func Untar(dir string, r io.Reader) error

Untar reads the tar file from r and writes it to dir. It can handle gzip-compressed tar files.

Note that Untar will overwrite any existing files with the same path as files in the archive.

Types

This section is empty.

Jump to

Keyboard shortcuts

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