fileutil

package
v1.5.8 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//EnvGoExeName 执行文件名称系统变量
	EnvGoExeName = "EnvGoExeName"
)

Variables

View Source
var (
	//DefaultFileMode 默认的文件权限 0640
	DefaultFileMode os.FileMode = 0640
	//DefaultFolderMode 默认的文件夹权限 0750
	DefaultFolderMode os.FileMode = 0750

	//DefaultFileFlag linux下需加上O_WRONLY或是O_RDWR
	DefaultFileFlag int = os.O_APPEND | os.O_CREATE | os.O_WRONLY
)
View Source
var (

	//ExeName 执行文件名称
	ExeName string
)

Functions

func ChangeFileExt

func ChangeFileExt(filename, newExt string) string

ChangeFileExt 更改文件后缀名 eg:filename=`../a/test/aa.txt` newExt=`.csv` -->return=`../a/test/aa.csv`

func DirExists

func DirExists(dir string) bool

DirExists 指定目录是否存在

func FileExists

func FileExists(dir string) bool

FileExists 指定文件是否存在

func FindFile

func FindFile(name string, flag int, perm os.FileMode) (*os.File, error)

FindFile 查找文件,根据初始化的文件目录顺序查找文件

func FindFullFilePath

func FindFullFilePath(name string) (string, error)

FindFullFilePath 查找相对目录文件的全路径文件 根据初始化的文件目录顺序查找文件(查文件不是查目录)

func FindFullPathPath

func FindFullPathPath(name string) (string, error)

FindFullPathPath 查找相对文件目录的全路径目录 根据初始化的文件目录顺序查找文件(查目录不是查文件)

func InitPathDirs

func InitPathDirs(retset bool, rootPaths ...string)

InitPathDirs 初始化工程文件根目录 retset:是否重置默认的目录列表 。 rootPaths:新增的目录列表,如果没有设置指定根目录并未重置默认的目录的话,文件搜索规则为: 1:命令执行所在目录、2:可执行文件所在目录、3:可执行文件上一级目录...新增的路径列表,否则直接按照给的文件名称查找文件。

func OpenFile

func OpenFile(pathfile string, fileflag int, filemode os.FileMode) (wc *os.File, err error)

OpenFile 打开文件,如果目录文件不存在则创建一个文件

func PathJoin

func PathJoin(dir, filename string) string

PathJoin 路径合并 并将 “\\” 转换成 “/”

func SetOSEnv

func SetOSEnv(option, value string)

SetOSEnv 设置环境变量

func TransPath

func TransPath(path string) string

TransPath 路径连接符转换 将路径 “\\” 转换成 “/”

Types

This section is empty.

Jump to

Keyboard shortcuts

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