fs

package
v0.0.0-...-c80f5a2 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Chmod

func Chmod(name string, mode os.FileMode) error

Chmod changes the mode of the named file to mode.

func ClearCache

func ClearCache(f File) error

ClearCache syncs and then removes the file's content from the OS cache.

func CopyDir

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

CopyDir recursively copies a directory tree, attempting to preserve permissions. Source directory must exist, destination directory must *not* exist.

func CopyFile

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

CopyFile copies file source to destination dest.

func Create

func Create(name string) (*os.File, error)

Create creates the named file with mode 0666 (before umask), truncating it if it already exists. If successful, methods on the returned File can be used for I/O; the associated file descriptor has mode O_RDWR. If there is an error, it will be of type *PathError.

func CreateSubfolder

func CreateSubfolder(path string) error

CreateSubfolder creates a folder recusively

func FormatWinPath

func FormatWinPath(path string) string

FormatWinPath replaces / with \

func Join

func Join(elem ...string) string

Join joins any number of path elements into a single path, adding a separating slash if necessary. The result is Cleaned; in particular, all empty strings are ignored.

func Lstat

func Lstat(name string) (os.FileInfo, error)

Lstat returns the FileInfo structure describing the named file. If the file is a symbolic link, the returned FileInfo describes the symbolic link. Lstat makes no attempt to follow the link. If there is an error, it will be of type *PathError.

func Mkdir

func Mkdir(name string, perm os.FileMode) error

Mkdir creates a new directory with the specified name and permission bits. If there is an error, it will be of type *PathError.

func MkdirAll

func MkdirAll(path string, perm os.FileMode) error

MkdirAll creates a directory named path, along with any necessary parents, and returns nil, or else returns an error. The permission bits perm are used for all directories that MkdirAll creates. If path is already a directory, MkdirAll does nothing and returns nil.

func OpenFile

func OpenFile(name string, flag int, perm os.FileMode) (*os.File, error)

OpenFile is the generalized open call; most users will use Open or Create instead. It opens the named file with specified flag (O_RDONLY etc.) and perm, (0666 etc.) if applicable. If successful, methods on the returned File can be used for I/O. If there is an error, it will be of type *PathError.

func Readlink(name string) (string, error)

Readlink returns the destination of the named symbolic link. If there is an error, it will be of type *PathError.

func Remove

func Remove(name string) error

Remove removes the named file or directory. If there is an error, it will be of type *PathError.

func RemoveAll

func RemoveAll(path string) error

RemoveAll removes path and any children it contains. It removes everything it can but returns the first error it encounters. If the path does not exist, RemoveAll returns nil (no error).

func RemoveUnc

func RemoveUnc(s string) string

RemoveUnc removes UNC from path

func Rename

func Rename(oldpath, newpath string) error

Rename renames (moves) oldpath to newpath. If newpath already exists, Rename replaces it. OS-specific restrictions may apply when oldpath and newpath are in different directories. If there is an error, it will be of type *LinkError.

func Stat

func Stat(name string) (os.FileInfo, error)

Stat returns a FileInfo structure describing the named file. If there is an error, it will be of type *PathError.

func Symlink(oldname, newname string) error

Symlink creates newname as a symbolic link to oldname. If there is an error, it will be of type *LinkError.

func UncPath

func UncPath(s string) string

UncPath converts an absolute Windows path to a UNC long path.

func Unzip

func Unzip(src, dest string) error

Unzip a file in a destination path https://stackoverflow.com/questions/20357223/easy-way-to-unzip-file-with-golang

func Walk

func Walk(root string, walkFn filepath.WalkFunc) error

Walk walks the file tree rooted at root, calling walkFn for each file or directory in the tree, including root. All errors that arise visiting files and directories are filtered by walkFn. The files are walked in lexical order, which makes the output deterministic but means that for very large directories Walk can be inefficient. Walk does not follow symbolic links.

Types

type File

type File interface {
	io.Reader
	io.Writer
	io.Closer

	Fd() uintptr
	Readdirnames(n int) ([]string, error)
	Readdir(int) ([]os.FileInfo, error)
	Seek(int64, int) (int64, error)
	Stat() (os.FileInfo, error)
}

File is an open file on a file system.

func Open

func Open(name string) (File, error)

Open opens a file for reading.

Jump to

Keyboard shortcuts

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