fs

package
v0.0.26 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AbsPath

func AbsPath(file_ string) string

AbsPath 返回文件的绝对路径 移除错误处理 e.g. a.txt -> /home/xxx/a.txt Makefile -> D:/SOFT/CODE/Makefile

func Append

func Append(src string, data string)

func ChangeFileType

func ChangeFileType(path string, type_ string) string

将文件类型换为特定类型的文件类型 返回相对路径 不需要带 . 后缀 例如 ChangeFileType("/home/xxx/xxx.go","txt") 返回 /home/xxx/xxx.txt ChangeFileType("xxx","mp4") 返回 xxx.mp4

func CmdPath

func CmdPath() string

获取当前命令窗口的路径 移除错误处理 e.g. CmdPath() -> /home/xxx CmdPath() -> D:/SOFT/CODE

func Copy

func Copy(src, dst string) error

func Create

func Create(src string, data string)

func DeepDir

func DeepDir(path string) ([]string, []string)

返回文件夹下的所有 文件 和 文件夹

func DeepDirSorted added in v0.0.26

func DeepDirSorted(path string) ([]string, []string)

返回文件夹下的所有 文件 和 文件夹 文件夹按深度排序

func Dir

func Dir(path string) ([]string, []string)

返回文件夹下的 所有文件 和 一级文件夹

func ExecutePath

func ExecutePath() string

返回可执行文件的路径 不包含可执行文件 不会因为在哪里运行而改变 起到了类似于 ./ 的作用

func FileName

func FileName(file_ string) string

返回文件名 不包含后缀 对于需要文件名包括后缀 应该使用filepath.Base(file_)方法 例如 /home/bin/xxx.go 返回 xxx test.go 返回 test

func FullFileName

func FullFileName(file_ string) string

返回文件的文件名 携带前缀的路径 并且一定为绝对路径

例如:/home/xxx/xxx.go 返回 /home/xxx/xxx

test.go 返回 /home/xxx/test

对于path.Dir()方法 区别就是可以对于相对路径也返回它的绝对路径的文件夹路径 需要文件名包括后缀 应该使用filepath.Base(file_)方法

func IsDir

func IsDir(file_ string) bool

判定文件是否为目录

func IsEmptyDir

func IsEmptyDir(path string) bool

判断是否为空目录

func IsExit

func IsExit(file_ string) bool

判断文件或者文件夹是否存在

func IsFileType

func IsFileType(file string, type_ string) bool

检查文件类型是否为特定类型 例如 main.go go true main.go txt false

func Move

func Move(sourcePath, destPath string) error

TODO use the panic or error ????

func Read

func Read(file string) string

读取文本文件

func Remove

func Remove(src string)

func SortByDepth added in v0.0.26

func SortByDepth(folders []string) []string

Types

This section is empty.

Jump to

Keyboard shortcuts

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