fst

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

File System Tools Dealing with directories (defining as a collection of files/directories here)

File System Tools Dealing with individual files here.

Index

Constants

View Source
const (
	KB, MB, GB, TB, PB, EB, ZB, YB = 1e3, 1e6, 1e9, 1e12, 1e15, 1e18, 1e21, 1e24
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BytesSI added in v0.1.0

type BytesSI float64

this type implementations based on https://golang.org/doc/effective_go

func (BytesSI) String added in v0.1.0

func (b BytesSI) String() string

type Directory

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

Directory{} should stay identical to reading an empty directory

func NewDirectory

func NewDirectory(p *Path, showHidden bool) *Directory

func NewDirectoryFromSlice added in v0.1.0

func NewDirectoryFromSlice(dir []os.DirEntry, showHidden bool) *Directory

This is for tests.

func (*Directory) Error added in v0.1.0

func (d *Directory) Error() string

func (*Directory) File

func (d *Directory) File(i int) File

func (*Directory) Files

func (d *Directory) Files() []File

func (*Directory) IsEmpty

func (d *Directory) IsEmpty() bool

func (*Directory) IsProblem added in v0.1.0

func (d *Directory) IsProblem() bool

func (*Directory) Read

func (d *Directory) Read(p *Path, showHidden bool)

func (*Directory) Size

func (d *Directory) Size() int

func (*Directory) Sort added in v0.1.0

func (d *Directory) Sort(method SortMethod)

Sorts slice of Files in place.

type File

type File struct {
	Name      string
	Size      BytesSI
	IsDir     bool
	IsReg     bool
	IsSymLink bool
	Time      time.Time
	Perm      fs.FileMode
}

Should use custom enum to restrict supported file types Implements os.DirEntry SHould think about the cost/benefit of reimplimenting DirEntry methods vs just composing?

func MakeFile

func MakeFile(d os.DirEntry) File

type Path

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

Path's job is to stay nice and neat instead of hoping string is formatted properly. Abstracting away from the base Go path stuff. *

func NewPath

func NewPath(s string) *Path

func (*Path) Copy

func (p1 *Path) Copy() *Path

func (*Path) Parent

func (p *Path) Parent() string

Should this return a Path? Is a string ever helpful?

func (*Path) Set

func (p *Path) Set(s string)

Set() must always store an absolute path compatibile with the standard path/filepath pkg

func (*Path) String

func (p *Path) String() string

String() must always keep compatibility with path/filepath pkg

func (*Path) ToParent added in v0.1.0

func (p *Path) ToParent()

type SortMethod added in v0.1.0

type SortMethod int
const (
	NameAsc SortMethod = iota
	NameDesc
	DirectoryAsc
	DirectoryDesc
)

Jump to

Keyboard shortcuts

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