file

package
v0.2.38 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BaseName

func BaseName(fullPath ...string) string

BaseName 函数返回路径中的文件名部分。 path 必需。规定要检查的路径。 suffix 可选。规定文件扩展名。如果文件有 suffix,则不会输出这个扩展名。

func BaseNameNoSuffix

func BaseNameNoSuffix(fullPath string) string

BaseNameNoSuffix 函数返回路径中的文件名部分,不带扩展名。 fullPath 必需。规定要检查的路径。

func DirName

func DirName(fullPath string) string

DirName 函数返回路径部分 fullPath 必需。规定要检查的路径。

func FileExist

func FileExist(fileName string) bool

FileExist 判断文件是否存在,存在返回true 不存在返回false

func GetContent

func GetContent(fullPath string) string

GetContent 获得文件内容

func GetExt

func GetExt(fullPath string) string

GetExt 获得文件后缀,扩展名

func GetFilesName

func GetFilesName(pathName string) []string

GetFilesName 获取目录下的所有文件名列表

func Mkdir

func Mkdir(path string)

Mkdir 创建目录

func PutContent

func PutContent(fullPath, content string)

PutContent 往文件写入数据

func PutContentAppend

func PutContentAppend(fullPath, content string)

PutContentAppend 往文件写入数据以追加的 形式

func PutContentBytes added in v0.0.67

func PutContentBytes(fullPath string, content []byte)

PutContentBytes 往文件写入数据

func PutContentBytesAppend added in v0.0.67

func PutContentBytesAppend(fullPath string, content []byte)

PutContentBytesAppend 往文件写入数据以追加的 形式

func Slash added in v0.0.10

func Slash(path string) string

Slash 根据系统返回正常的路径

func SlashR added in v0.0.10

func SlashR(path string) string

SlashR 将'\'转为'/'

Types

type File

type File struct {
	// contains filtered or unexported fields
}

File 文件类

func (*File) Ext

func (f *File) Ext() string

Ext 文件后缀名

func (*File) FullPath

func (f *File) FullPath() string

FullPath 文件完整路径

func (*File) ModifyTime

func (f *File) ModifyTime() int

ModifyTime 文件修改时间

func (*File) Name

func (f *File) Name() string

Name 文件名

func (*File) Path

func (f *File) Path() string

Path 文件路径

func (*File) ReadAll

func (f *File) ReadAll() ([]byte, error)

ReadAll 读取全部

func (*File) ReadBlock

func (f *File) ReadBlock(size int64) ([]byte, int64)

ReadBlock 读取块

func (*File) ReadLine

func (f *File) ReadLine() ([]byte, error)

ReadLine 读取一行

func (*File) Size

func (f *File) Size() int64

Size 获得文件大小

func (*File) Truncate

func (f *File) Truncate()

Truncate 清空文件

func (*File) Write

func (f *File) Write(b []byte)

Write 写入

func (*File) WriteAppend

func (f *File) WriteAppend(b []byte)

WriteAppend 追加文件

func (*File) WriteAt

func (f *File) WriteAt(b []byte, offset int64) int

WriteAt 在固定点写入

type Filer

type Filer interface {
	Size() int64
	ReadAll() ([]byte, error)
	ReadLine() ([]byte, error)
	ReadBlock(size int64) ([]byte, int64)
	Write(b []byte)
	WriteAt(b []byte, offset int64) int
	WriteAppend(b []byte)
	Truncate()
	Ext() string
	Name() string
	Path() string
	FullPath() string
	ModifyTime() int
}

Filer 文件接口

func NewFile

func NewFile(fullPath string) Filer

NewFile 新建文件

Jump to

Keyboard shortcuts

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