paths

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Home, Config, Cache string

Functions

func Exists

func Exists(path string) bool

Check if a file or directory exists at path.

func PrependHome

func PrependHome(path string) string

Prepend Home to this path.

func Resolve

func Resolve(path string) (string, error)

Expects path to be an absolute path that can be resolved, otherwise it's made absolute by filepath.Abs, or in the event of failure, Home is prepended and then checked. If all operations fail, fs.ErrNotExist is returned.

Types

type FileInfo

type FileInfo struct {
	Path      string    `json:"path"`
	IsRegular bool      `json:"is_regular"`
	IsDir     bool      `json:"is_dir"`
	Name      string    `json:"filename"`
	Size      int64     `json:"size"`
	Modified  time.Time `json:"modified"`
}

Stores information on a file.

func Open

func Open(p string) (FileInfo, error)

Calls os.Open and then os.File.Stat to populate FileInfo.

Fatal on os.File.Stat errors.

func (*FileInfo) Equals

func (fi *FileInfo) Equals(other *FileInfo) bool

Determines if this *FileInfo is the same as [other] by comparing [FileInfo.Name], [FileInfo.Size] & [FileInfo.Modified].

func (FileInfo) ModifiedString

func (fi FileInfo) ModifiedString() string

Return terminal friendly modified string.

func (*FileInfo) Newer

func (fi *FileInfo) Newer(other *FileInfo) bool

Determines if this *FileInfo is newer than [other].

func (FileInfo) String

func (fi FileInfo) String() string

Return terminal friendly string.

type Path

type Path string

A Path is just a string that can be operated on.

All operations are platform agnostic.

func (*Path) Exists

func (p *Path) Exists() bool

Check if this *Path Exists on the system.

func (*Path) Resolve

func (p *Path) Resolve() (string, error)

Calls Resolve on this *Path.

func (Path) String

func (p Path) String() string

Return Path as a string.

Jump to

Keyboard shortcuts

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