Remove Relative method from Locator

The Relative method added to the Locator interface was
not correctly implemented in the file type. The root was
never set when instantiating the object.

This change removes this method from the interface and the file
type, switching to a local implementation in the mounts type
instead.

Signed-off-by: Evan Lezar <elezar@nvidia.com>
This commit is contained in:
Evan Lezar 2022-07-15 16:40:21 +02:00
parent 37ee972f74
commit acc0afbb7a
2 changed files with 0 additions and 11 deletions

View File

@ -28,7 +28,6 @@ import (
// prefixes. The validity of a file is determined by a filter function.
type file struct {
logger *log.Logger
root string
prefixes []string
filter func(string) error
}
@ -78,15 +77,6 @@ func (p file) Locate(pattern string) ([]string, error) {
return filenames, nil
}
// Relative returns the path relative to the root for the file locator
func (p file) Relative(path string) (string, error) {
if p.root == "" || p.root == "/" {
return path, nil
}
return filepath.Rel(p.root, path)
}
// assertFile checks whether the specified path is a regular file
func assertFile(filename string) error {
info, err := os.Stat(filename)

View File

@ -21,5 +21,4 @@ package lookup
// Locator defines the interface for locating files on a system.
type Locator interface {
Locate(string) ([]string, error)
Relative(string) (string, error)
}