files

package
v0.0.0-...-f4a649d Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2025 License: GPL-3.0 Imports: 41 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyCustomAppFile

func CopyCustomAppFile(srcPath, dstPath string) error

func DetectBinary

func DetectBinary(buf []byte) bool

func DownloadFileWithProxy

func DownloadFileWithProxy(url, dst string) error

func GetDecoderByName

func GetDecoderByName(name string) encoding.Encoding

func GetGroup

func GetGroup(gid uint32) string

func GetMimeType

func GetMimeType(path string) string

func GetParentMode

func GetParentMode(path string) (os.FileMode, error)
func GetSymlink(path string) string

func GetUsername

func GetUsername(uid uint32) string

func IsBlockDevice

func IsBlockDevice(mode os.FileMode) bool

func IsEmptyDir

func IsEmptyDir(dir string) bool

func IsHidden

func IsHidden(path string) bool

func IsInvalidChar

func IsInvalidChar(name string) bool
func IsSymlink(mode os.FileMode) bool

func ReadFileByLine

func ReadFileByLine(filename string, page, pageSize int, latest bool) (res *dto.LogFileRes, err error)

func TailFromEnd

func TailFromEnd(filename string, lines int) ([]string, error)

func ZipFile

func ZipFile(files []archiver.File, dst afero.File) error

Types

type CompressType

type CompressType string
const (
	Zip      CompressType = "zip"
	Gz       CompressType = "gz"
	Bz2      CompressType = "bz2"
	TarBz2   CompressType = "tar.bz2"
	Tar      CompressType = "tar"
	TarGz    CompressType = "tar.gz"
	Tgz      CompressType = "tgz"
	Xz       CompressType = "xz"
	TarXz    CompressType = "tar.xz"
	SdkZip   CompressType = "sdkZip"
	SdkTarGz CompressType = "sdkTarGz"
	Rar      CompressType = "rar"
	X7z      CompressType = "7z"
)

type DirSize

type DirSize struct {
	Path string `json:"path"`
	Size int64  `json:"size"`
}

type FileInfo

type FileInfo struct {
	Fs         afero.Fs    `json:"-"`
	Path       string      `json:"path"`
	Name       string      `json:"name"`
	User       string      `json:"user"`
	Group      string      `json:"group"`
	Uid        string      `json:"uid"`
	Gid        string      `json:"gid"`
	Extension  string      `json:"extension"`
	Content    string      `json:"content"`
	Size       int64       `json:"size"`
	IsDir      bool        `json:"isDir"`
	IsSymlink  bool        `json:"isSymlink"`
	IsHidden   bool        `json:"isHidden"`
	LinkPath   string      `json:"linkPath"`
	Type       string      `json:"type"`
	Mode       string      `json:"mode"`
	MimeType   string      `json:"mimeType"`
	UpdateTime time.Time   `json:"updateTime"`
	ModTime    time.Time   `json:"modTime"`
	FileMode   os.FileMode `json:"-"`
	Items      []*FileInfo `json:"items"`
	ItemTotal  int         `json:"itemTotal"`
	FavoriteID uint        `json:"favoriteID"`
	IsDetail   bool        `json:"isDetail"`
}

func NewFileInfo

func NewFileInfo(op FileOption) (*FileInfo, error)

type FileOp

type FileOp struct {
	Fs afero.Fs
}

func NewFileOp

func NewFileOp() FileOp

func (FileOp) ChmodR

func (f FileOp) ChmodR(dst string, mode int64, sub bool) error

func (FileOp) ChmodRWithMode

func (f FileOp) ChmodRWithMode(dst string, mode fs.FileMode, sub bool) error

func (FileOp) ChownR

func (f FileOp) ChownR(dst string, uid string, gid string, sub bool) error

func (FileOp) CleanDir

func (f FileOp) CleanDir(dst string) error

func (FileOp) Compress

func (f FileOp) Compress(srcRiles []string, dst string, name string, cType CompressType, secret string) error

func (FileOp) Copy

func (f FileOp) Copy(src, dst string) error

func (FileOp) CopyAndReName

func (f FileOp) CopyAndReName(src, dst, name string, cover bool) error

func (FileOp) CopyDir

func (f FileOp) CopyDir(src, dst string) error

func (FileOp) CopyDirWithExclude

func (f FileOp) CopyDirWithExclude(src, dst string, excludeNames []string) error

func (FileOp) CopyDirWithNewName

func (f FileOp) CopyDirWithNewName(src, dst, newName string) error

func (FileOp) CopyFile

func (f FileOp) CopyFile(src, dst string) error

func (FileOp) CreateDir

func (f FileOp) CreateDir(dst string, mode fs.FileMode) error

func (FileOp) CreateDirWithMode

func (f FileOp) CreateDirWithMode(dst string, mode fs.FileMode) error

func (FileOp) CreateDirWithPath

func (f FileOp) CreateDirWithPath(isDir bool, pathItem string) (string, error)

func (FileOp) CreateFile

func (f FileOp) CreateFile(dst string) error

func (FileOp) CreateFileWithMode

func (f FileOp) CreateFileWithMode(dst string, mode fs.FileMode) error

func (FileOp) Cut

func (f FileOp) Cut(oldPaths []string, dst, name string, cover bool) error

func (FileOp) Decompress

func (f FileOp) Decompress(srcFile string, dst string, cType CompressType, secret string) error

func (FileOp) DecompressGzFile

func (f FileOp) DecompressGzFile(srcFile, dst string) error

func (FileOp) DeleteDir

func (f FileOp) DeleteDir(dst string) error

func (FileOp) DeleteFile

func (f FileOp) DeleteFile(dst string) error

func (FileOp) DownloadFile

func (f FileOp) DownloadFile(url, dst string) error

func (FileOp) DownloadFileWithProcess

func (f FileOp) DownloadFileWithProcess(url, dst, key string, ignoreCertificate bool) error

func (FileOp) GetContent

func (f FileOp) GetContent(dst string) ([]byte, error)

func (FileOp) GetDepthDirSize

func (f FileOp) GetDepthDirSize(path string) ([]DirSize, error)

func (FileOp) GetDirSize

func (f FileOp) GetDirSize(path string) (int64, error)

func (FileOp) LinkFile

func (f FileOp) LinkFile(source string, dst string, isSymlink bool) error

func (FileOp) Mv

func (f FileOp) Mv(oldPath, dstPath string) error

func (FileOp) OpenFile

func (f FileOp) OpenFile(dst string) (fs.File, error)

func (FileOp) Rename

func (f FileOp) Rename(oldName string, newName string) error

func (FileOp) RmRf

func (f FileOp) RmRf(dst string) error

func (FileOp) SaveFile

func (f FileOp) SaveFile(dst string, content string, mode fs.FileMode) error

func (FileOp) SaveFileWithByte

func (f FileOp) SaveFileWithByte(dst string, content []byte, mode fs.FileMode) error

func (FileOp) Stat

func (f FileOp) Stat(dst string) bool

func (FileOp) TarGzCompressPro

func (f FileOp) TarGzCompressPro(withDir bool, src, dst, secret, exclusionRules string) error

func (FileOp) TarGzExtractPro

func (f FileOp) TarGzExtractPro(src, dst string, secret string) error

func (FileOp) TarGzFilesWithCompressPro

func (f FileOp) TarGzFilesWithCompressPro(list []string, dst, secret string) error

func (FileOp) WriteFile

func (f FileOp) WriteFile(dst string, in io.Reader, mode fs.FileMode) error

type FileOption

type FileOption struct {
	Path       string `json:"path"`
	Search     string `json:"search"`
	ContainSub bool   `json:"containSub"`
	Expand     bool   `json:"expand"`
	Dir        bool   `json:"dir"`
	ShowHidden bool   `json:"showHidden"`
	Page       int    `json:"page"`
	PageSize   int    `json:"pageSize"`
	SortBy     string `json:"sortBy"`
	SortOrder  string `json:"sortOrder"`
	IsDetail   bool   `json:"isDetail"`
}

type FileSearchInfo

type FileSearchInfo struct {
	Path string `json:"path"`
	fs.FileInfo
}

type Process

type Process struct {
	Total   uint64  `json:"total"`
	Written uint64  `json:"written"`
	Percent float64 `json:"percent"`
	Name    string  `json:"name"`
}

type RarArchiver

type RarArchiver struct {
}

func (RarArchiver) Compress

func (z RarArchiver) Compress(sourcePaths []string, dstFile string, _ string) (err error)

func (RarArchiver) Extract

func (z RarArchiver) Extract(filePath, dstDir string, _ string) error

type ShellArchiver

type ShellArchiver interface {
	Extract(filePath, dstDir string, secret string) error
	Compress(sourcePaths []string, dstFile string, secret string) error
}

func NewRarArchiver

func NewRarArchiver() ShellArchiver

func NewShellArchiver

func NewShellArchiver(compressType CompressType) (ShellArchiver, error)

func NewTarArchiver

func NewTarArchiver(compressType CompressType) ShellArchiver

func NewTarGzArchiver

func NewTarGzArchiver() ShellArchiver

func NewX7zArchiver

func NewX7zArchiver() ShellArchiver

func NewZipArchiver

func NewZipArchiver() ShellArchiver

type TarArchiver

type TarArchiver struct {
	Cmd          string
	CompressType CompressType
}

func (TarArchiver) Compress

func (t TarArchiver) Compress(sourcePaths []string, dstFile string, secret string) error

func (TarArchiver) Extract

func (t TarArchiver) Extract(FilePath string, dstDir string, secret string) error

type TarGzArchiver

type TarGzArchiver struct {
}

func (TarGzArchiver) Compress

func (t TarGzArchiver) Compress(sourcePaths []string, dstFile string, secret string) error

func (TarGzArchiver) Extract

func (t TarGzArchiver) Extract(filePath, dstDir string, secret string) error

type WriteCounter

type WriteCounter struct {
	Total   uint64
	Written uint64
	Key     string
	Name    string
}

func (*WriteCounter) SaveProcess

func (w *WriteCounter) SaveProcess()

func (*WriteCounter) Write

func (w *WriteCounter) Write(p []byte) (n int, err error)

type X7zArchiver

type X7zArchiver struct {
}

func (X7zArchiver) Compress

func (z X7zArchiver) Compress(sourcePaths []string, dstFile string, _ string) (err error)

func (X7zArchiver) Extract

func (z X7zArchiver) Extract(filePath, dstDir string, _ string) error

type ZipArchiver

type ZipArchiver struct {
}

func (ZipArchiver) Compress

func (z ZipArchiver) Compress(sourcePaths []string, dstFile string, _ string) error

func (ZipArchiver) Extract

func (z ZipArchiver) Extract(filePath, dstDir string, secret string) error

Jump to

Keyboard shortcuts

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