iox

package
v0.0.0-...-85e1034 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Byte  = 1
	KByte = Byte * 1024
	MByte = KByte * 1024
	GByte = MByte * 1024
	TByte = GByte * 1024
	PByte = TByte * 1024
	EByte = PByte * 1024
)

Storage unit constants.

Variables

This section is empty.

Functions

func Copy

func Copy(src, dest string) error

Copy copies file from source to target path.

func CopyDir

func CopyDir(srcPath, destPath string, filters ...func(filePath string) bool) error

CopyDir copy files recursively from source to target directory.

The filter accepts a function that process the path info. and should return true for need to filter.

It returns error when error occurs in underlying functions.

func CopyDir1

func CopyDir1(srcPath string, destPath string) error

*

  • 拷贝文件夹,同时拷贝文件夹中的文件
  • @param srcPath 需要拷贝的文件夹路径: D:/test
  • @param destPath 拷贝到的位置: D:/backup/

func CopyFile

func CopyFile(src, dest string) (w int64, err error)

生成目录并拷贝文件

func DirExistOrCreate

func DirExistOrCreate(path string, is_create bool) (bool, error)

检测文件夹路径时候存在

func FileCTime

func FileCTime(file string) (time.Time, error)

获取创建时间

func FileCTimeInt64

func FileCTimeInt64(file string) (int64, error)

获取创建时间

func FileCTimeString

func FileCTimeString(file string) (string, error)

获取创建时间

func FileMTime

func FileMTime(file string) (time.Time, error)

获取文件修改时间

func FileMTimeInt64

func FileMTimeInt64(file string) (int64, error)

获取文件修改时间

func FileMTimeString

func FileMTimeString(file string) (string, error)

获取文件修改时间

func FileSize

func FileSize(file string) (int64, error)

获取文件大小

func FileSizeHumane

func FileSizeHumane(s uint64) string

FileSizeHumane calculates the file size and generate user-friendly string.

func FileSizeString

func FileSizeString(file string) string

获取文件大小带单位

func GetAllSubDirs

func GetAllSubDirs(rootPath string) ([]string, error)

GetAllSubDirs returns all subdirectories of given root path. Slice does not include given path itself.

func GetFileInfo

func GetFileInfo(file_path string) (_full_name, _suffix, _file_name string)

获取文件名,后缀信息 req: "D:/software/Typora/bin/typora.exe" resp: typora.exe , .exe , typora

func GetFileListBySuffix

func GetFileListBySuffix(dirPath, suffix string) ([]string, error)

GetFileListBySuffix returns an ordered list of file paths. It recognize if given path is a file, and don't do recursive find.

func GetGopaths

func GetGopaths() []string

func GetHomeDir

func GetHomeDir() (home string, _err error)

func GetMP4Duration

func GetMP4Duration(reader io.ReaderAt) (lengthOfTime uint32, err error)

GetMP4Duration 获取视频时长,以秒计

func GetSrcpath

func GetSrcpath(importPath string) (_appPath string, _err error)

func IsDir

func IsDir(fileAddr string) bool

判断是否为目录

func IsExist

func IsExist(path string) bool

目录或文件是否存在

func IsFile

func IsFile(filePath string) bool

文件是否存在

func LgetAllSubDirs

func LgetAllSubDirs(rootPath string) ([]string, error)

LgetAllSubDirs returns all subdirectories of given root path, including following symbolic links, if any. Slice does not include given path itself.

func LstatDir

func LstatDir(rootPath string, includeDir ...bool) ([]string, error)

LstatDir gathers information of given directory by depth-first. It returns slice of file list, follows symbolic links and includes subdirectories if enabled; it returns error and nil slice when error occurs in underlying functions, or given path is not a directory or does not exist.

Slice does not include given path itself. If subdirectories is enabled, they will have suffix '/'.

func SecondToTime

func SecondToTime(sec int64) time.Time

把秒级的时间戳转为time格式

func StatDir

func StatDir(rootPath string, includeDir ...bool) ([]string, error)

StatDir gathers information of given directory by depth-first. It returns slice of file list and includes subdirectories if enabled; it returns error and nil slice when error occurs in underlying functions, or given path is not a directory or does not exist.

Slice does not include given path itself. If subdirectories is enabled, they will have suffix '/'.

func WalkDir

func WalkDir(dir string, suffix []string) (_files []string, _err error)

获取指定目录及所有子目录下的所有文件,可以匹配后缀过滤。

func WriteFile

func WriteFile(filename string, data []byte) error

WriteFile writes data to a file named by filename. If the file does not exist, WriteFile creates it and its upper level paths.

Types

type BoxHeader

type BoxHeader struct {
	Size       uint32
	HeaderType [4]byte
	Size64     uint64
}

BoxHeader 信息头

Jump to

Keyboard shortcuts

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