Filesystem For Golang
go get github.com/go-component/filesystem
import "github.com/go-component/filesystem"
support single or multiple for file operation
// single
Mkdir("a", 0755)
// multiple
Mkdir([]string{"a", "b"}, 0755)
func AppendToFile(fileName string, content []byte) error
Appends content to a file.
func Chmod(files interface{}, mode os.FileMode) error
Change mode for an array of files or directories.
func ChmodWithRecur(files interface{}, mode os.FileMode) error
Change mode for an array of files or directories with recursive mode.
func Chown(files interface{}, user, group int) error
Change the owner of an array of files or directories.
func ChownWithRecur(files interface{}, user, group int) error
Change the owner of an array of files or directories recursive mode.
func Copy(srcFileName string, dstFileName string) error
Copies a file.
func Dirname(fileName string) string
Return dirname.
func Exists(paths interface{}) bool
Checks the existence of files or directories.
func Hardlink(srcFileName string, dstFileName string) error
Creates a hard link, or several hard links to files.
func IsAbsolutePath(fileName string) bool
Return whether the file path is an absolute path.
func IsDir(path string) bool
Returns whether the file path is a directory.
func IsFile(path string) bool
Returns whether the file path is a file.
func IsReadable(fileName string) bool
Tells whether a file exists and is readable.
func IsWritable(fileName string) bool
Tells whether a file exists and is writable.
func Mkdir(paths interface{}, mode os.FileMode) error
Creates a directory of directory or directories.
func Readlink(path string) (string, error)
Resolves links in paths.
func Remove(files interface{}) error
Remove removes the named file or (empty) directory.
func RemoveWithRecur(files interface{}) error
Remove removes the named file or directory with recursive mode.
func Rename(srcFileName string, dstFileName string) error
Rename src to dst.
func ResolveFilesAndDirs(dirPath string) (files []string, dirs []string, err error)
Resolves files and directories.
func Symlink(srcDirName string, dstDirName string) error
Creates a symbolic link or copy a directory.
func Touch(files interface{}) error
Creates new files if not exist.
func TouchFromTime(files interface{}, atime time.Time, mtime time.Time) error
Sets access and modification time of files.