ospath

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2023 License: MIT Imports: 4 Imported by: 2

Documentation

Index

Examples

Constants

View Source
const AllPaths = InstallPaths | DataPaths
View Source
const InstallPaths = BinPath | LibPath | DocPath

Variables

This section is empty.

Functions

func KeepAbs

func KeepAbs(path string, rel func(string) string) string

func MustDir added in v0.6.1

func MustDir(perm fs.FileMode, forfile string) (file string)

func ProvideDir added in v0.6.1

func ProvideDir(perm fs.FileMode, forfile string) (file string, err error)

Types

type App added in v0.6.1

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

func NewApp added in v0.6.1

func NewApp(set AppPaths, app ...string) App

func (App) Bin added in v0.6.1

func (a App) Bin(rel ...string) string

func (App) BinPath added in v0.6.1

func (a App) BinPath(rel string) string

func (App) CheckDirs added in v0.6.2

func (a App) CheckDirs(flags AppPath) (res AppPath, err error)

func (App) Doc added in v0.6.1

func (a App) Doc(rel ...string) string

func (App) DocPath added in v0.6.1

func (a App) DocPath(rel string) string

func (App) Lib added in v0.6.1

func (a App) Lib(rel ...string) string

func (App) LibPath added in v0.6.1

func (a App) LibPath(rel string) string

func (App) LocalData added in v0.6.1

func (a App) LocalData(rel ...string) string

func (App) LocalDataPath added in v0.6.1

func (a App) LocalDataPath(rel string) string

func (App) ProvideDirs added in v0.6.2

func (a App) ProvideDirs(perm fs.FileMode, flags AppPath) error

func (App) RoamingData added in v0.6.1

func (a App) RoamingData(rel ...string) string

func (App) RoamingDataPath added in v0.6.1

func (a App) RoamingDataPath(rel string) string

type AppPath added in v0.6.2

type AppPath int
const (
	BinPath AppPath = (1 << iota)
	LibPath
	DocPath
	LocalDataPath
	RoamingDataPath
)

func (AppPath) All added in v0.6.2

func (ap AppPath) All(flags AppPath) bool

func (AppPath) Any added in v0.6.2

func (ap AppPath) Any(flags AppPath) bool

type AppPaths added in v0.6.1

type AppPaths interface {
	Bin(app ...string) string
	Lib(app ...string) string
	Doc(app ...string) string
	LocalData(app ...string) string
	RoamingData(app ...string) string
}

type DesktopUserApp added in v0.6.1

type DesktopUserApp string

func NewDesktopUserApp added in v0.6.1

func NewDesktopUserApp(username string) DesktopUserApp

func (DesktopUserApp) Bin added in v0.6.1

func (u DesktopUserApp) Bin(app ...string) string

func (DesktopUserApp) Doc added in v0.6.1

func (u DesktopUserApp) Doc(app ...string) string

func (DesktopUserApp) Lib added in v0.6.1

func (u DesktopUserApp) Lib(app ...string) string

func (DesktopUserApp) LocalData added in v0.6.1

func (u DesktopUserApp) LocalData(app ...string) string

func (DesktopUserApp) RoamingData added in v0.6.1

func (u DesktopUserApp) RoamingData(app ...string) string

type DirTree added in v0.6.2

type DirTree struct {
	RelBin         string
	RelLib         string
	RelDoc         string
	RelLocalData   string
	RelRoamingData string
	// contains filtered or unexported fields
}
Example
d := NewDirTree("basedir", nil)
app := NewApp(d, "example-app")
fmt.Println(app.Bin("executable"))
fmt.Println(app.Lib("sample.so"))
fmt.Println(app.Doc("README.md"))
fmt.Println(app.LocalData("local.data"))
fmt.Println(app.RoamingData("roaming.data"))
Output:

basedir/executable
basedir/lib/sample.so
basedir/doc/README.md
basedir/data/local.data
basedir/roaming/roaming.data

func ExeDirTree added in v0.6.2

func ExeDirTree(init *DirTree) *DirTree

func NewDirTree added in v0.6.2

func NewDirTree(basedir string, init *DirTree) *DirTree

func (*DirTree) Bin added in v0.6.2

func (d *DirTree) Bin(_ ...string) string

func (*DirTree) Doc added in v0.6.2

func (d *DirTree) Doc(_ ...string) string

func (*DirTree) Lib added in v0.6.2

func (d *DirTree) Lib(_ ...string) string

func (*DirTree) LocalData added in v0.6.2

func (d *DirTree) LocalData(_ ...string) string

func (*DirTree) RoamingData added in v0.6.2

func (d *DirTree) RoamingData(_ ...string) string

type SingleDir added in v0.6.1

type SingleDir string
Example
d := SingleDir("basedir")
app := NewApp(d, "example-app")
fmt.Println(app.Bin("executable"))
fmt.Println(app.Lib("sample.so"))
fmt.Println(app.Doc("README.md"))
fmt.Println(app.LocalData("local.data"))
fmt.Println(app.RoamingData("roaming.data"))
Output:

basedir/executable
basedir/sample.so
basedir/README.md
basedir/local.data
basedir/roaming.data

func ExeDir

func ExeDir() SingleDir

func (SingleDir) Bin added in v0.6.1

func (d SingleDir) Bin(_ ...string) string

func (SingleDir) Doc added in v0.6.1

func (d SingleDir) Doc(_ ...string) string

func (SingleDir) Lib added in v0.6.1

func (d SingleDir) Lib(_ ...string) string

func (SingleDir) LocalData added in v0.6.1

func (d SingleDir) LocalData(_ ...string) string

func (SingleDir) RoamingData added in v0.6.1

func (d SingleDir) RoamingData(_ ...string) string

Jump to

Keyboard shortcuts

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