2022-12-14 22:41:37 +00:00
|
|
|
package filer
|
|
|
|
|
2023-06-19 12:37:29 +00:00
|
|
|
// RootPath can be joined with a relative path and ensures that
|
|
|
|
// the returned path is always a strict child of the root path.
|
2023-06-18 23:37:01 +00:00
|
|
|
type RootPath interface {
|
2023-06-19 12:37:29 +00:00
|
|
|
// Join returns the specified path name joined to the root.
|
|
|
|
// It returns an error if the resulting path is not a strict child of the root path.
|
2023-06-18 23:37:01 +00:00
|
|
|
Join(string) (string, error)
|
2023-06-19 12:37:29 +00:00
|
|
|
|
2023-06-18 23:37:01 +00:00
|
|
|
Root() string
|
2022-12-14 22:41:37 +00:00
|
|
|
}
|
|
|
|
|
2023-06-18 23:37:01 +00:00
|
|
|
type NopRootPath struct{}
|
2022-12-14 22:41:37 +00:00
|
|
|
|
2023-06-18 23:37:01 +00:00
|
|
|
func (rp NopRootPath) Join(name string) (string, error) {
|
|
|
|
return name, nil
|
|
|
|
}
|
2022-12-14 22:41:37 +00:00
|
|
|
|
2023-06-18 23:37:01 +00:00
|
|
|
func (rp NopRootPath) Root() string {
|
|
|
|
return ""
|
2022-12-14 22:41:37 +00:00
|
|
|
}
|