Documentation ¶
Overview ¶
Package files
Package files ¶
Package files
Index ¶
- Constants
- Variables
- func ClearFile(f string) error
- func Copy(src, dst string) error
- func CreateFile(f string, perm os.FileMode, dirPerm os.FileMode) (*os.File, error)
- func GetContent(f string) []byte
- func GetFileMode(f string) os.FileMode
- func GetModTime(f string) time.Time
- func GetSize(f string) int64
- func GetSizeReadable(f string) string
- func IsExist(path string) bool
- func IsFile(path string) bool
- func IsFolder(path string) bool
- func IsZip(f string) bool
- func MkDir(p string, perm os.FileMode) error
- func Name(f string) string
- func RmDir(p string) error
- func RmFile(f string) error
- func SetFileMode(f string, perm os.FileMode) error
- func SetFileOwn(f string, uid int, gid int) error
- func Sync(dst, src string) error
- func SyncTo(to string, srcs ...string) error
- func TmpFile(f string) (*os.File, error)
- func UnZip(f string, target string) error
- func Zip(f string, target string) error
- type FileInfo
- type Syncer
Constants ¶
View Source
const ( KB = 1 << 10 MB = KB << 10 GB = MB << 10 TB = GB << 10 )
Variables ¶
View Source
var (
ErrFileOverDir = errors.New(
"fsync: trying to overwrite a non-empty directory with a file")
)
Functions ¶
func CreateFile ¶
CreateFile 创建文件如果不存在
func SetFileOwn ¶
SetFileOwn chown修改属主 user id group id
Types ¶
type Syncer ¶
type Syncer struct { // Set this to true to delete files in the destination that don't exist // in the source. Delete bool // To allow certain files to remain in the destination, implement this function. // Return true to skip file, false to delete. // Note that src may be either os.FileInfo or fs.DirEntry depending on the file system. DeleteFilter func(f FileInfo) bool // By default, modification times are synced. This can be turned off by // setting this to true. NoTimes bool // NoChmod disables permission mode syncing. NoChmod bool // Implement this function to skip Chmod syncing for only certain files // or directories. Return true to skip Chmod. ChmodFilter func(dst, src os.FileInfo) bool SrcFs afero.Fs DestFs afero.Fs // exclude Exclude []string ExcludeFunc func(f FileInfo) bool }
Type Syncer provides functions for syncing files.
func NewSyncer ¶
func NewSyncer() *Syncer
NewSyncer creates a new instance of Syncer with default options.
Click to show internal directories.
Click to hide internal directories.