filieutil

package
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type File

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

func New

func New(path string) (*File, error)

New read the file path and return a file object

func (*File) Clean

func (f *File) Clean()

Clean clean the file

func (*File) GetChildren

func (f *File) GetChildren() ([]*File, error)

GetChilren based on the current folder get all the children files

func (*File) GetName

func (f *File) GetName() string

GetName get the file name

func (*File) GetPath

func (f *File) GetPath() string

GetPath get the file path

func (*File) GetPrefix

func (f *File) GetPrefix() string

GetPrefix get the file prefix name demo: test.abc return test

func (*File) GetSuffix

func (f *File) GetSuffix() string

GetSuffix get the file suffix name demo: test.abc return .abc

func (*File) IsDir

func (f *File) IsDir() bool

IsDir the file is a folder

func (*File) MkdirAll

func (f *File) MkdirAll(name string) (*File, error)

MkdirAll based on the current folder create a new folder if the name path is file then return error

func (*File) Move

func (f *File) Move(path string) error

Move based on the current file move to a new file file move to a new file

func (*File) Paste

func (f *File) Paste(newpath string) error

Paste based on the current file paste to a new file

func (*File) Read

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

Read based on reading current file data and return the file bytes

func (*File) Remove

func (f *File) Remove() error

Remove remove the current file remove the current file the file object will be reset

func (*File) Rename

func (f *File) Rename(name string) error

Rename based on the current file rename to a new file file rename to a new file

func (*File) Replace

func (f *File) Replace(newFile *File)

Replace based on the current file replace to a new file

func (*File) Size

func (f *File) Size() int64

Size get the file size

type IFile

type IFile interface {
	Read() ([]byte, error)               // based on reading current file data and return the file bytes
	GetPath() string                     // get the file path
	GetName() string                     // get the file name
	GetPrefix() string                   // get the file prefix name demo: test.abc return test
	GetSuffix() string                   // get the file suffix name demo: test.abc return .abc
	Size() int64                         // get the file size
	IsDir() bool                         // the file is a folder
	MkdirAll(name string) (*File, error) // based on the current folder create a new folder
	Remove() error                       // remove the current file
	Rename(name string) error            // based on the current file rename to a new file
	Move(path string) error              // based on the current file move to a new file
	Paste(newpath string) error          // based on the current file paste to a new file

	GetChildren() ([]*File, error) // based on the current folder get all the children files
	Clean()                        // clean the file
	Replace(newFile *File)         // based on the current file replace to a new file
	// contains filtered or unexported methods
}

IFile 文件工具接口

Jump to

Keyboard shortcuts

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