filepath

package
v0.0.0-...-ebc58a5 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TWalkIterator = &gad.Type{TypeName: "WalkIterator", Parent: gad.TIterator}
	Module        = gad.Dict{
		"ext":          gad.MustNewReflectValue(filepath.Ext),
		"clean":        gad.MustNewReflectValue(filepath.Clean),
		"join":         gad.MustNewReflectValue(filepath.Join),
		"base":         gad.MustNewReflectValue(filepath.Base),
		"dir":          gad.MustNewReflectValue(filepath.Dir),
		"isAbs":        gad.MustNewReflectValue(filepath.IsAbs),
		"isLocal":      gad.MustNewReflectValue(filepath.IsLocal),
		"rel":          gad.MustNewReflectValue(filepath.Rel),
		"volumeName":   gad.MustNewReflectValue(filepath.VolumeName),
		"split":        gad.MustNewReflectValue(filepath.Split),
		"match":        gad.MustNewReflectValue(filepath.Match),
		"fromSlash":    gad.MustNewReflectValue(filepath.FromSlash),
		"evalSymlinks": gad.MustNewReflectValue(filepath.EvalSymlinks),
		"walk": &gad.BuiltinFunction{
			Name:  "walk",
			Value: Walk,
		},
		TWalkSkip.TypeName: TWalkSkip,
		"glob": &gad.BuiltinFunction{
			Name: "glob",
			Value: func(c gad.Call) (_ gad.Object, err error) {
				if err = c.Args.CheckLen(1); err != nil {
					return
				}

				var (
					matched []string
					arr     gad.Array
				)

				if matched, err = filepath.Glob(c.Args.GetOnly(0).ToString()); err != nil {
					return
				}

				arr = make(gad.Array, len(matched))

				for i, v := range matched {
					arr[i] = gad.Str(v)
				}

				return arr, nil
			},
		},
		"splitList": &gad.BuiltinFunction{
			Name: "splitList",
			Value: func(c gad.Call) (_ gad.Object, err error) {
				if err = c.Args.CheckLen(1); err != nil {
					return
				}

				var (
					s   = filepath.SplitList(c.Args.GetOnly(0).ToString())
					arr = make(gad.Array, len(s))
				)

				for i, v := range s {
					arr[i] = gad.Str(v)
				}

				return arr, nil
			},
		},
	}
)
View Source
var TWalkSkip = &gad.Type{
	Parent:   gad.TInt,
	TypeName: "WalkSkip",
	Constructor: &gad.Function{
		Value: NewSkipMode,
	},
	Static: gad.Dict{
		"None": WalkSkipNone,
		"Dir":  WalkSkipDir,
		"All":  WalkSkipAll,
	},
}

Functions

func NewSkipMode

func NewSkipMode(c gad.Call) (_ gad.Object, err error)

func Walk

func Walk(c gad.Call) (_ gad.Object, err error)

Types

type WalkSkip

type WalkSkip uint64
const (
	WalkSkipNone WalkSkip = iota
	WalkSkipDir
	WalkSkipAll
)

func (*WalkSkip) Clear

func (f *WalkSkip) Clear(flag WalkSkip) *WalkSkip

func (WalkSkip) Equal

func (f WalkSkip) Equal(right gad.Object) bool

func (WalkSkip) Has

func (f WalkSkip) Has(flag WalkSkip) bool

func (WalkSkip) IsFalsy

func (f WalkSkip) IsFalsy() bool

func (*WalkSkip) Parse

func (f *WalkSkip) Parse(str string)

func (*WalkSkip) Set

func (f *WalkSkip) Set(flag WalkSkip) *WalkSkip

func (WalkSkip) String

func (f WalkSkip) String() string

func (WalkSkip) ToString

func (f WalkSkip) ToString() string

func (*WalkSkip) Toggle

func (f *WalkSkip) Toggle(flag WalkSkip) *WalkSkip

func (WalkSkip) Type

func (f WalkSkip) Type() gad.ObjectType

Jump to

Keyboard shortcuts

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