mirror of
https://github.com/MontFerret/ferret.git
synced 2025-03-23 21:51:08 +02:00
32 lines
682 B
Go
32 lines
682 B
Go
|
package path
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
"path"
|
||
|
|
||
|
"github.com/MontFerret/ferret/pkg/runtime/core"
|
||
|
"github.com/MontFerret/ferret/pkg/runtime/values"
|
||
|
"github.com/MontFerret/ferret/pkg/runtime/values/types"
|
||
|
)
|
||
|
|
||
|
// IsAbs reports whether the path is absolute.
|
||
|
// @params path (String) - The path.
|
||
|
// @returns (Boolean) - True if the path is absolute.
|
||
|
func IsAbs(_ context.Context, args ...core.Value) (core.Value, error) {
|
||
|
err := core.ValidateArgs(args, 1, 1)
|
||
|
|
||
|
if err != nil {
|
||
|
return values.False, err
|
||
|
}
|
||
|
|
||
|
err = core.ValidateType(args[0], types.String)
|
||
|
|
||
|
if err != nil {
|
||
|
return values.None, err
|
||
|
}
|
||
|
|
||
|
pathText := args[0].String()
|
||
|
|
||
|
return values.NewBoolean(path.IsAbs(pathText)), nil
|
||
|
}
|