file

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Package file contains utilities for operating on files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Append

func Append(name string, content []byte) error

Append appends content to a file.

func Compress added in v0.5.0

func Compress(name string, w io.Writer) io.WriteCloser

Compress compresses a writer

func Copy

func Copy(oldpath, newpath string) error

Copy copies a file from src to dst.

func Create

func Create(name string) error

Create creates a file.

func Decompress added in v0.5.0

func Decompress(name string, r io.Reader) (io.ReadCloser, error)

Decompress decompresses a reader It will return a raw reader if the reader is not compressed

func DownloadWithCache

func DownloadWithCache(ctx context.Context, cacheDir, src, dest string, mode fs.FileMode, quiet bool) error

DownloadWithCache downloads the src file to the dest file.

func DownloadWithCacheAndExtract

func DownloadWithCacheAndExtract(ctx context.Context, cacheDir, src, dest string, match string, mode fs.FileMode, quiet bool, clean bool) error

DownloadWithCacheAndExtract downloads the src file to the dest file, and extract it to the dest directory.

func Exists

func Exists(name string) bool

Exists checks if a file exists.

func MkdirAll added in v0.4.0

func MkdirAll(name string) error

MkdirAll creates a directory.

func Open added in v0.3.0

func Open(name string) (io.WriteCloser, error)

Open opens/creates a file for writing.

func Read added in v0.4.0

func Read(name string) ([]byte, error)

Read reads the content of a file.

func Remove added in v0.3.0

func Remove(name string) error

Remove removes a file.

func RemoveAll added in v0.4.0

func RemoveAll(name string) error

RemoveAll removes a directory and all its contents.

func Rename added in v0.4.0

func Rename(oldpath, newpath string) error

Rename renames a file.

func Write added in v0.4.0

func Write(name string, content []byte) error

Write writes content to a file.

func WriteWithMode added in v0.4.0

func WriteWithMode(name string, content []byte, mode os.FileMode) error

WriteWithMode writes content to a file with the given mode.

Types

This section is empty.

Jump to

Keyboard shortcuts

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