files

package
v2.29.0 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const PermDir = 0755
View Source
const PermFile = 0644

Variables

This section is empty.

Functions

func IsNamedPipe added in v2.10.0

func IsNamedPipe(mode os.FileMode) bool

func IsSupportedSubtitle added in v2.29.0

func IsSupportedSubtitle(fileName string) bool
func IsSymlink(mode os.FileMode) bool

Types

type FileInfo

type FileInfo struct {
	*Listing
	Fs        afero.Fs          `json:"-"`
	Path      string            `json:"path"`
	Name      string            `json:"name"`
	Size      int64             `json:"size"`
	Extension string            `json:"extension"`
	ModTime   time.Time         `json:"modified"`
	Mode      os.FileMode       `json:"mode"`
	IsDir     bool              `json:"isDir"`
	IsSymlink bool              `json:"isSymlink"`
	Type      string            `json:"type"`
	Subtitles []string          `json:"subtitles,omitempty"`
	Content   string            `json:"content,omitempty"`
	Checksums map[string]string `json:"checksums,omitempty"`
	Token     string            `json:"token,omitempty"`

	Resolution *ImageResolution `json:"resolution,omitempty"`
	// contains filtered or unexported fields
}

FileInfo describes a file.

func NewFileInfo

func NewFileInfo(opts *FileOptions) (*FileInfo, error)

NewFileInfo creates a File object from a path and a given user. This File object will be automatically filled depending on if it is a directory or a file. If it's a video file, it will also detect any subtitles.

func (*FileInfo) Checksum

func (i *FileInfo) Checksum(algo string) error

Checksum checksums a given File for a given User, using a specific algorithm. The checksums data is saved on File object.

func (*FileInfo) RealPath added in v2.21.0

func (i *FileInfo) RealPath() string

type FileOptions

type FileOptions struct {
	Fs         afero.Fs
	Path       string
	Modify     bool
	Expand     bool
	ReadHeader bool
	Token      string
	Checker    rules.Checker
	Content    bool
}

FileOptions are the options when getting a file info.

type ImageResolution added in v2.27.0

type ImageResolution struct {
	Width  int `json:"width"`
	Height int `json:"height"`
}

type Listing

type Listing struct {
	Items    []*FileInfo `json:"items"`
	NumDirs  int         `json:"numDirs"`
	NumFiles int         `json:"numFiles"`
	Sorting  Sorting     `json:"sorting"`
}

Listing is a collection of files.

func (Listing) ApplySort

func (l Listing) ApplySort()

ApplySort applies the sort order using .Order and .Sort

type Sorting

type Sorting struct {
	By  string `json:"by"`
	Asc bool   `json:"asc"`
}

Sorting contains a sorting order.

Jump to

Keyboard shortcuts

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