fscopy

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2022 License: MIT Imports: 4 Imported by: 0

README

Go Reference Go Report Card Build Status codecov

Package fscopy implements file system copy functions not present in standard library.

fscopy.Dir( "/home/nofeatures/dst-dir", "/home/nofeatures/source-dir" )
fscopy.File( "/home/nofeatures/dst-file", "/home/nofeatures/source-file" )
fscopy.Into( "/home/nofeatures/dst-dir", "/tmp/file1", "/tmp/file2", "/tmp/some-dir" )

The types of environments where I intend to use this package are somewhat manicured and highly unlikely to experience issues related to symlinks or circular references. As such this package has no logic or consideration for symlinks. However fscopy.Dir() does have a low-effort mechanism to track src-to-dst copies that have already occurred and will not duplicate its efforts.

Test Coverage

I don't expect test coverage for this package will ever achieve 100%. The majority of statements that are not covered are return errors.Go(err) (essentially return err) where os.Stat() or os.File.Close() or io.Copy() have returned a non-nil error. While I could put in the efforts to mock such operations I don't feel the extra complexity would be worth the trade off in code coverage.

Documentation

Overview

Package fscopy implements a few file system copy functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dir

func Dir(dst, src string) error

Dir recursively copies src/* into dst/. If dst does not exist it is created with os.MkdirAll().

func File

func File(dst, src string) error

File copies src file to dst. If dst already exists it is overwritten.

func Glob

func Glob(globs ...string) ([]string, error)

Glob calls filepath.Glob() on each glob. If any glob returns an error it is skipped and the next glob is processed; if an error is returned it contains the globs that failed.

Matches from globs are deduped while adding them to the return value.

func Into

func Into(dst string, src ...string) error

Into copies each src into dst/. If dst does not exist it is created with mode 0770. If a src is a directory then its location in dst is dst/+basename(src).

Types

This section is empty.

Jump to

Keyboard shortcuts

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