file

package
v2.6.0 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2023 License: GPL-3.0 Imports: 9 Imported by: 61

Documentation

Overview

Package file provides simple utility functions to be used with files

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Copy

func Copy(src, dst string) error

Copy copies the file or directory from source path to destination path with the standart copy environment. For more control create a custom copy environment.

func Delete

func Delete(file string) bool

Delete 删除文件

func Exists

func Exists(file string) bool

Exists checks whether the given file exists or not. It panics if an error is occured. Use ExistsOk to use the returned error.

func ExistsOk

func ExistsOk(file string) (bool, error)

ExistsOk checks whether the given file exists or not.

func GetAbsolutePath

func GetAbsolutePath(subfolder ...string) (string, error)

GetAbsolutePath 获取当前执行文件的绝对路径目录 subfolder 子目录,如果没有,自动创建

func GetCurrentPath

func GetCurrentPath() (string, error)

GetCurrentPath 获取当前执行文件的路径

func IsFile

func IsFile(file string) bool

IsFile checks wether the given file is a directory or not. It panics if an error is occured. Use IsFileOk to use the returned error.

func IsFileOk

func IsFileOk(file string) (bool, error)

IsFileOk checks whether the given file is a directory or not.

func IsUserFile

func IsUserFile(fi os.FileInfo) bool

IsUserFile ignores editor backups, hidden files and folders/symlinks.

func MkdirAll

func MkdirAll(file string) bool

MkdirAll 创建文件夹 @param file 文件夹路径

func PrintFile

func PrintFile(name string)

打印文件里的文本内容

func WriteFile

func WriteFile(name string, content []byte, append bool) bool

WriteFile 写入内容到文件 @param name 文件名 @param content 内容 @param append 是否追加到末尾

Types

type CopyEnv

type CopyEnv struct {
	FollowSymbolicLinks bool
	Overwrite           bool
	Verbose             bool
}

CopyEnv describes the environment in which a copy is invoked.

func (*CopyEnv) Copy

func (c *CopyEnv) Copy(src, dst string) error

type FileInfo

type FileInfo struct {
	Exists bool
	os.FileInfo
}

FileInfo describes a file. It's a wrapper around os.FileInfo.

func Stat

func Stat(file string) (*FileInfo, error)

Stat returns a FileInfo describing the named file. It's a wrapper around os.Stat.

Jump to

Keyboard shortcuts

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