fileutils

package module
v0.0.0-...-517eb18 Latest Latest
Warning

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

Go to latest
Published: May 17, 2020 License: MIT Imports: 9 Imported by: 2

README

file-utils

File Utilities

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyBytes

func CopyBytes(in []byte, dst string) (err error)

func CopyFile

func CopyFile(src, dst string) (err error)

CopyFile copies a file from src to dst. If src and dst files exist, and are the same, then return success. Otherise, attempt to create a hard link between the two files. If that fail, copy the file contents from src to dst.

func CopyFileContents

func CopyFileContents(src, dst string) (err error)

CopyFileContents copies the contents of the file named src to the file named by dst. The file will be created if it does not already exist. If the destination file exists, all it's contents will be replaced by the contents of the source file.

func CopyReader

func CopyReader(in io.Reader, dst string) (err error)

func CopyReaderInfo

func CopyReaderInfo(in io.Reader, info os.FileInfo, dst string) (err error)

func CopyTree

func CopyTree(dest string, sources []Copier) (err error)

func CreateFile

func CreateFile(filename string, r io.Reader, info os.FileInfo, opt WriteMode) (err error)

CreateFile writes data to a file named by filename. If the file does not exist, CreateFile creates it with permissions perm; otherwise CreateFile truncates it before writing.

func CreateFileSync

func CreateFileSync(filename string, r io.Reader, info os.FileInfo) (err error)

CreateFileSync writes data to a file named by filename and set perms and times. If the file does not exist, CreateFile creates it with permissions perm; otherwise CreateFile truncates it before writing.

func SetInfo

func SetInfo(pth string, info os.FileInfo) (err error)

Types

type Copier

type Copier interface {
	CopyTo(dir string) (err error)
}

type Destation

type Destation struct {
	Dest string
}

func (Destation) Check

func (d Destation) Check(dir string) (pth string, err error)

type Dir

type Dir struct {
	Src string
	Destation
	Ignore []func(pth string) bool
}

func (*Dir) CopyTo

func (s *Dir) CopyTo(dest string) (err error)

func (*Dir) GetSrc

func (d *Dir) GetSrc() string

type Sourcer

type Sourcer interface {
	Copier
	GetSrc() string
}

type Src

type Src struct {
	Src  string
	Info *os.FileInfo
	Destation
}

func (*Src) CopyTo

func (s *Src) CopyTo(dest string) (err error)

func (*Src) GetSrc

func (s *Src) GetSrc() string

type SrcData

type SrcData struct {
	Data []byte
	Info *os.FileInfo
	Destation
}

func (*SrcData) CopyTo

func (s *SrcData) CopyTo(dest string) (err error)

type SrcReader

type SrcReader struct {
	Info   *os.FileInfo
	Reader io.Reader
	Destation
}

func (*SrcReader) CopyTo

func (s *SrcReader) CopyTo(dest string) (err error)

type WriteMode

type WriteMode int
const (
	WO_SetPerm WriteMode = 1 << iota
	WO_SetTimes
	Wo_Sync
	WO_ALL = WO_SetPerm | WO_SetTimes
)

func (WriteMode) IsSetPerm

func (f WriteMode) IsSetPerm() bool

func (WriteMode) IsSetTimes

func (f WriteMode) IsSetTimes() bool

func (WriteMode) IsSync

func (f WriteMode) IsSync() bool

Jump to

Keyboard shortcuts

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