fileutil

package
v2.1.11 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2022 License: MIT Imports: 12 Imported by: 93

Documentation

Overview

Package fileutil implements some basic functions for file operations

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClearFile

func ClearFile(path string) error

ClearFile write empty string to path file

func CopyFile

func CopyFile(srcFilePath string, dstFilePath string) error

CopyFile copy src file to dest file

func CreateDir added in v2.0.9

func CreateDir(absPath string) error

CreateDir create directory in absolute path. param `absPath` like /a/, /a/b/

func CreateFile

func CreateFile(path string) bool

CreateFile create a file in path

func FileMode

func FileMode(path string) (fs.FileMode, error)

FileMode return file's mode and permission

func IsDir

func IsDir(path string) bool

IsDir checks if the path is directory or not

func IsExist

func IsExist(path string) bool

IsExist checks if a file or directory exists

func IsLink(path string) bool

IsLink checks if a file is symbol link or not

func ListFileNames

func ListFileNames(path string) ([]string, error)

ListFileNames return all file names in the path

func MiMeType

func MiMeType(file any) string

MiMeType return file mime type param `file` should be string(file path) or *os.File

func ReadFileByLine

func ReadFileByLine(path string) ([]string, error)

ReadFileByLine read file line by line

func ReadFileToString

func ReadFileToString(path string) (string, error)

ReadFileToString return string of file content

func RemoveFile

func RemoveFile(path string) error

RemoveFile remove the path file

func UnZip

func UnZip(zipFile string, destPath string) error

UnZip unzip the file and save it to destPath

func Zip

func Zip(fpath string, destPath string) error

Zip create zip file, fpath could be a single file or a directory

Types

This section is empty.

Jump to

Keyboard shortcuts

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