Documentation ¶
Index ¶
- func CloseIfIsCloser(r any) error
- func CopyAllContent(srcDir string, dstDir string) error
- func CopyContent(src string, dst string) error
- func Exists(path string) (bool, error)
- func List(dirPath string) ([]string, error)
- func ListALlDirs(dirPath string) ([]string, error)
- func ListAll(dirPath string) ([]string, error)
- func ListAllFiles(dirPath string) ([]string, error)
- func ListDirs(dirPath string) ([]string, error)
- func ListFiles(dirPath string) ([]string, error)
- func Lowercase(path string) error
- func LowercaseAll(dirPath string) error
- func MkFile(filePath string) (*os.File, error)
- func MkFileFromBytes(filePath string, b []byte) error
- func MkFileFromReader(filePath string, r io.Reader) error
- func MkFilesFromBytes(goroutines int, s ...PathWithContent) error
- func MkParents(filePath string) error
- func MoveAllContent(srcDir string, dstDir string) error
- func MoveContent(src string, dst string) error
- type PathWithContent
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CloseIfIsCloser ¶ added in v0.11.0
func CopyAllContent ¶ added in v0.10.0
CopyAllContent copies all files from srcDir to dstDir recursively. Only files' name and content are guaranteed to be the same. Only files are copied, (empty) directories are ignored. Any existing files will be overridden.
func CopyContent ¶ added in v0.10.0
CopyContent copies the file src to dst. Only the file's name and content are guaranteed to be the same. The parents will be created if they don't exist. The existing file will be overridden.
func Exists ¶ added in v0.7.0
Exists checks if the file or directory exists. If Exists cannot determinate whether the file or directory exists (e.g., permission error), it returns an error.
func List ¶ added in v0.11.0
List lists all files and directories under the directory dirPath (no recursive).
func ListALlDirs ¶ added in v0.11.0
ListALlDirs lists all directories under the directory dirPath (recursive).
func ListAll ¶ added in v0.10.0
ListAll lists all files and directories under the directory dirPath (recursive).
func ListAllFiles ¶ added in v0.10.0
ListAllFiles lists all files under the directory dirPath (recursive).
func ListDirs ¶ added in v0.11.0
ListDirs lists all directories under the directory dirPath (no recursive).
func ListFiles ¶ added in v0.11.0
ListFiles lists all files under the directory dirPath (no recursive).
func Lowercase ¶ added in v0.10.0
Lowercase renames the file or directory to lowercase. If the file or directory is already lower-cased, it does nothing.
func LowercaseAll ¶
LowercaseAll renames the directory to lowercase recursively. If a file or directory is already lower-cased, LowercaseAll does nothing to it.
func MkFile ¶ added in v0.10.0
MkFile creates a file and its parents with respectively mode 0666 and 0755 (both before unmask). If the parents of the file already exist, MkFile does nothing. If the file already exist, MkFile truncates it.
func MkFileFromBytes ¶ added in v0.10.0
MkFileFromBytes calls MkFile and then writes the content of the bytes to the file.
func MkFileFromReader ¶ added in v0.10.0
MkFileFromReader calls MkFile and then writes the content of the reader to the file.
If the reader implements io.Closer, it would be closed when the method returns.
func MkFilesFromBytes ¶ added in v1.0.0
func MkFilesFromBytes(goroutines int, s ...PathWithContent) error
func MkParents ¶ added in v0.10.0
MkParents creates all parents of a file with mode 0755 (before unmask). If the parents of the file already exist, MkParents does nothing.
func MoveAllContent ¶ added in v0.10.0
MoveAllContent moves all files from srcDir to dstDir recursively. Only files' name and content are guaranteed to be the same. Only files are moved, (empty) directories are ignored. Any existing files will be overridden.
Use MoveAllContent to prevent os.Rename to panic "invalid cross-device link".
func MoveContent ¶ added in v0.10.0
MoveContent moves the file src to dst. Only the file's name and content are guaranteed to be the same. The parents will be created if they don't exist. The existing file will be overridden.