Path

package
v0.5.9 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2022 License: BSL-1.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Check

func Check(path string) (pathExits bool, err error)

Check checks existence of provided path, returns error if error is not *PathError

func CheckDir

func CheckDir(path string) (isDir bool, err error)

CheckDir checks if path exists and leads to a directory

Types

type ItemGetter

type ItemGetter struct {
	Path, Filter                string
	Include, Exclude, Extension []string
	Directory, Recurse          bool
}

ItemGetter is the helper struct for the GetItems method Fields can be set one by one, mis-modifications to Path gets fixed by fixPath

func NewItemGetter

func NewItemGetter(path string) *ItemGetter

NewItemGetter inits ItemGetter with path and returns a ItemGetter struct.

func (*ItemGetter) GetItems

func (IG *ItemGetter) GetItems() (dirEntries []os.DirEntry, err error)

GetItems is a Go native Get-ChildItem from PowerShell, although not all flags are provided. See https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/get-childitem for params info. path will default to "." if empty, everything else can be the initial value for the var type if not required.

Filter is cross-platform case-sensitive Include and Exclude are case-insensitive on Windows Extension is case-insensitive

func (*ItemGetter) GetItemsString

func (IG *ItemGetter) GetItemsString() ([]string, error)

GetItemsString collects filenames and returns a slice of string. Calls GetItems and appends each os.DirEntry.Name() to returned []string.

func (*ItemGetter) Set

func (IG *ItemGetter) Set(filter string, include, exclude, extension []string, directory, recurse bool)

Set sets the additional params from ItemGetter

Jump to

Keyboard shortcuts

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