43 lines
902 B
Go
43 lines
902 B
Go
package path
|
|
|
|
import "path"
|
|
import "strings"
|
|
import "html/template"
|
|
import "path/filepath"
|
|
import "git.tebibyte.media/sashakoshka/step"
|
|
|
|
const hiddenPrefix = "."
|
|
|
|
var _ step.FuncProvider = new(Provider)
|
|
|
|
// Provider provides path functions.
|
|
type Provider struct {
|
|
|
|
}
|
|
|
|
// FuncMap fulfills the step.FuncProvider interface.
|
|
func (this *Provider) FuncMap () template.FuncMap {
|
|
return template.FuncMap {
|
|
"isHidden": funcIsHidden,
|
|
"osIsHidden": funcOSIsHidden,
|
|
"joinPaths": funcJoinPaths,
|
|
"osJoinPaths": funcOSJoinPaths,
|
|
}
|
|
}
|
|
|
|
func funcIsHidden (name string) bool {
|
|
return strings.HasPrefix(path.Base(name), hiddenPrefix)
|
|
}
|
|
|
|
func funcOSIsHidden (name string) bool {
|
|
return strings.HasPrefix(filepath.Base(name), hiddenPrefix)
|
|
}
|
|
|
|
func funcJoinPaths (left, right string) string {
|
|
return path.Join(left, right)
|
|
}
|
|
|
|
func funcOSJoinPaths (left, right string) string {
|
|
return path.Join(left, right)
|
|
}
|