Documentation ¶
Overview ¶
Copyright (C) 2019 tisnyo <tisnyo@gmail.com>.
package file contains some file operations. license that can be found in the LICENSE file.
Index ¶
- func AbsPath(relPath string) (string, error)
- func AppendFile(path string) (*os.File, error)
- func ChangeWorkDir(path string) error
- func CopyFile(src string, dest string) (bool, error)
- func CopyFileTo(src string, dir string) (bool, error)
- func Crc32(src string) (string, error)
- func CreateDir(path string) error
- func CreateDirs(path string) error
- func CreateFile(path string) (*os.File, error)
- func Delete(path string) bool
- func DeleteAll(path string) bool
- func Exists(path string) bool
- func FixPath(input string) string
- func GetFile(path string) (*os.File, error)
- func GetFileExt(filePath string) string
- func GetFileInfo(path string) (os.FileInfo, error)
- func GetFileMd5(fi string) (string, error)
- func GetTempDir() string
- func GetWorkDir() (string, error)
- func IsAbsPath(path string) bool
- func IsDir1(path string) bool
- func IsDir2(file *os.File) bool
- func IsFile1(path string) bool
- func IsFile2(file *os.File) bool
- func ListFiles(path string) ([]os.FileInfo, error)
- func MoveFile(src string, dest string) error
- func OpenFile(path string, flag int, perm os.FileMode) (*os.File, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppendFile ¶
AppendFile opens a file to append or creates it if it is not exist.
func ChangeWorkDir ¶
ChangeWorkDir changes the current working directory to the named directory.
func CopyFileTo ¶
CopyFileTo copies a file to target dir.
func CreateDirs ¶
CreateDirs creates a directory named path, along with any necessary parents, and returns nil, or else returns an error. The permission bits perm (before umask) are used for all directories that MkdirAll creates. If path is already a directory, MkdirAll does nothing and returns nil.
func CreateFile ¶
CreateFile creates a new file, truncating it if it already exists
func DeleteAll ¶
DeleteAll deletes file or directory. if it is a directory, it will try to delete all files below. special: it returns true if the file not exists.
func FixPath ¶
FixPath fixed file path in a simple way, examples:
"/aaa/aa\\bb\\cc/d/////" -> "/aaa/aa/bb/cc/d" "E:/aaa/aa\\bb\\cc/d////e/" -> "E:/aaa/aa/bb/cc/d/e" "" -> "." "/" -> "/"
func GetFileExt ¶
GetFileExt returns the file name extension used by path. The extension is the suffix beginning at the final dot in the final slash-separated element of path; it is empty if there is no dot.
func GetFileInfo ¶
GetFileInfo gets the file information.
func GetTempDir ¶
func GetTempDir() string
GetTempDir returns the default directory to use for temporary files. On Unix systems, it returns $TMPDIR if non-empty, else /tmp. On Windows, it uses GetTempPath, returning the first non-empty value from %TMP%, %TEMP%, %USERPROFILE%, or the Windows directory. On Plan 9, it returns /tmp. The directory is neither guaranteed to exist nor have accessible permissions.
func GetWorkDir ¶
GetWorkDir returns a rooted path name corresponding to the current directory. If the current directory can be reached via multiple paths (due to symbolic links), Getwd may return any one of them.
func ListFiles ¶
ListFiles reads the directory named by dirname and returns a list of directory entries sorted by filename.
func OpenFile ¶
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 (before umask), 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.
Copy from os.OpenFile.
Types ¶
This section is empty.