myfile

package
v1.8.7 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2024 License: BSD-3-Clause Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BytesToFile

func BytesToFile(path string, data []byte) error

BytesToFile writes data to a file. If the file does not exist it will be created with permission mode 0644.

func ClearFile

func ClearFile(path string) error

ClearFile clears a file content.

func Create

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

Create creates or truncates the target file specified by path. If the parent directory does not exist, it will be created with mode os.ModePerm. If the file does not exist, it is created with mode 0666. If successful, methods on the returned file can be used for I/O; the associated file descriptor has mode O_RDWR.

func CreateFile

func CreateFile(filePath string) error

CreateFile creates a file specified by path.

func FileMD5

func FileMD5(path string) (string, error)

FileMD5 gets file MD5。

func FileMD5Reader

func FileMD5Reader(r io.Reader) (string, error)

FileMD5Reader gets file MD5 from io.Reader.

func FileSize

func FileSize(path string) (int64, error)

FileSize gets file size in bytes.

func FileSizeFile

func FileSizeFile(file *os.File) (int64, error)

FileSizeFile gets file size from os.File in bytes.

func FileToBytes

func FileToBytes(path string) []byte

FileToBytes serialize the file to bytes.

func IsDir

func IsDir(path string) bool

func IsDirE

func IsDirE(path string) (bool, error)

func IsExist

func IsExist(path string) (bool, error)

func IsFile

func IsFile(path string) bool

func IsFileE

func IsFileE(path string) (bool, error)

func IsShortcut

func IsShortcut(path string) bool

IsShortcut checks a file whether is a shortcut on Windows.

func IsSymlink(path string) bool

func IsSymlinkE

func IsSymlinkE(path string) (bool, error)

func ListDir

func ListDir(dir string) ([]string, error)

func ListDirEntryPaths

func ListDirEntryPaths(dirname string, cur bool) ([]string, error)

ListDirEntryPaths lists all the file or directory paths in the directory recursively. If the cur is true result will include current directory. Note that GetDirAllEntryPaths won't follow symlink if the subdir is a symbolic link.

func ListDirEntryPathsSymlink(dirname string, cur bool) ([]string, error)

ListDirEntryPathsSymlink lists all the file or dir paths in the directory recursively. If the cur is true result will include current directory.

func ListFileNames

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

ListFileNames lists all file names in the directory.

func ReadLines

func ReadLines(path string) ([]string, int, error)

func RemoveFile

func RemoveFile(path string) error

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

Types

This section is empty.

Jump to

Keyboard shortcuts

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