mirror of
https://github.com/photoprism/photoprism.git
synced 2025-12-12 00:34:13 +01:00
Signed-off-by: Michael Mayer <michael@photoprism.app>
This commit is contained in:
21
pkg/fs/resolve.go
Normal file
21
pkg/fs/resolve.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package fs
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
// Resolve returns the absolute file path, with all symlinks resolved.
|
||||
func Resolve(filePath string) (string, error) {
|
||||
if filePath == "" {
|
||||
return "", errors.New("no such file or directory")
|
||||
}
|
||||
|
||||
if target, err := filepath.EvalSymlinks(filePath); err != nil {
|
||||
return "", errors.New("no such file or directory")
|
||||
} else if target, err = filepath.Abs(target); target != "" {
|
||||
return target, err
|
||||
} else {
|
||||
return filepath.Abs(filePath)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user