fs

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	WorkingDirectory = workingDirectory()
	ExecuteDirectory = executorDirectory()
	HomeDirectory    = os.Getenv("HOME")
	TempDirectory    = os.TempDir()
)

Functions

func AbsPath

func AbsPath(file_ string) string

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

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 CheckCrossDriverLinux

func CheckCrossDriverLinux(src, dst string) bool

func CheckCrossDriverWindows

func CheckCrossDriverWindows(src, dst string) bool

func CmdPath

func CmdPath() string

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

func DeepDir

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

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

func DeepDirSorted

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

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

func Dir

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

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

func ExecutePath

func ExecutePath() string

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

func FileName

func FileName(src string) string

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

func FullFileName

func FullFileName(src string) string

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

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

test.go 返回 /home/xxx/test

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

func IsDir

func IsDir(file_ string) bool

判定文件是否为目录

func IsEmptyDir

func IsEmptyDir(path string) bool

判断是否为空目录

func IsExist

func IsExist(file_ string) bool

func IsExit

func IsExit(src string) bool

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

func IsFile

func IsFile(file_ string) bool

func IsFileType

func IsFileType(file string, type_ string) bool

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

func ListDir

func ListDir(_src string) (srcNames []string, _dirNames []string)

func ListDirDeep

func ListDirDeep(_src string) (srcs []string, _folders []string)

func MoveFile

func MoveFile(src, dst string) (err error)

func SortByDepth

func SortByDepth(folders []string) []string

func WslPathConvent

func WslPathConvent(_wslPath string) string

cover windows path to wsl path D:\soft\code --> /mnt/d/soft/code

Types

This section is empty.

Jump to

Keyboard shortcuts

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