fpath

package
v0.0.0-...-b81b7c8 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2024 License: MIT Imports: 12 Imported by: 28

Documentation

Overview

Package fpath implements cross-platform file and object path handling.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplicationDir

func ApplicationDir(subdir ...string) string

ApplicationDir returns best base directory for specific OS.

func AtomicWriteFile

func AtomicWriteFile(outfile string, data []byte, _ os.FileMode) (err error)

AtomicWriteFile is a helper to atomically write the data to the outfile.

func EditFile

func EditFile(fileToEdit string) error

EditFile opens the best OS-specific text editor we can find.

func GetTempData

func GetTempData(ctx context.Context) (string, bool, bool)

GetTempData returns if temporary data should be stored in memory or on disk.

func IsRoot

func IsRoot(path string) bool

IsRoot returns whether path is the root directory.

func IsValidSetupDir

func IsValidSetupDir(name string) (ok bool, err error)

IsValidSetupDir checks if directory is valid for setup configuration.

func IsWritable

func IsWritable(filepath string) (bool, error)

IsWritable determines if a directory is writeable.

func WithTempData

func WithTempData(ctx context.Context, directory string, inmemory bool) context.Context

WithTempData creates context with information how store temporary data, in memory or on disk.

Types

type FPath

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

FPath is an OS independent path handling structure.

func New

func New(p string) (FPath, error)

New creates new FPath from the given URL.

func (FPath) Base

func (p FPath) Base() string

Base returns the last segment of the path.

func (FPath) Bucket

func (p FPath) Bucket() string

Bucket returns the first segment of path.

func (FPath) IsLocal

func (p FPath) IsLocal() bool

IsLocal returns whether the path refers to local or remote location.

func (FPath) Join

func (p FPath) Join(segment string) FPath

Join is appends the given segment to the path.

func (FPath) Path

func (p FPath) Path() string

Path returns the URL path without the scheme.

func (FPath) String

func (p FPath) String() string

String returns the entire URL (untouched).

Jump to

Keyboard shortcuts

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