utils

package module
v0.0.0-...-6294e63 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2022 License: Apache-2.0 Imports: 4 Imported by: 0

README

Test Coverage

Utils for billy.Filesystem based filesystem

This package contains following most commanly used utility functions


Installation

import utils "github.com/daveamit/go-billy-filesystem-utils" 

CopyFile

CopyFile is just a sugared wrapper over CopyFileWithParams with overwrite set to true and perms set to 0700

Sample CopyFile usage

func main()  {
	bfs := osfs.New("path/to/root/dir")

    err := utils.CopyFile(bfs, "src-file", "dst-file")
    if err != nil {
        panic(err)
    }
}

CopyFileWithParams

CopyFileWithParams takes src, dst, overwrite flag which indicates if the dst is to be overwritten or not in case it already exists and perms. As the name suggests, the function calls src to dst, it creates dst with given perms

Sample CopyFile usage

func main()  {
	bfs := osfs.New("path/to/root/dir")

    err := utils.CopyFileWithParams(bfs, "src-file", "dst-file", true, 0700)
    if err != nil {
        panic(err)
    }
}

more functions to come

  • CopyDir
  • CopyDirWithParams
  • MoveFile
  • MoveFileWithParams
  • MoveDir
  • MoveDirWithParams
  • (suggest more ...)

License

This package is distributed under the Apache License Version 2.0, see LICENSE for details.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrResourceIsNotAFile = errors.New("the resource specified is not a file")

ErrResourceIsNotAFile is returned if resource is not a file, but a dir or something.

Functions

func CopyFile

func CopyFile(fs billy.Filesystem, src string, dst string) error

CopyFile is essentially CopyFileWithParams with overwrite set to true and perm set to 0700

func CopyFileWithParams

func CopyFileWithParams(bfs billy.Filesystem, src string, dst string, overwrite bool, perm os.FileMode) error

Types

This section is empty.

Jump to

Keyboard shortcuts

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