blob: c2cc6ce5d4965a10d0af5087addf7f90152d472b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
// Copyright 2022 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Package safefilepath manipulates operating-system file paths.
package safefilepath
import (
"errors"
"io/fs"
)
var errInvalidPath = errors.New("invalid path")
// Localize is filepath.Localize.
//
// It is implemented in this package to avoid a dependency cycle
// between os and file/filepath.
//
// Tests for this function are in path/filepath.
func Localize(path string) (string, error) {
if !fs.ValidPath(path) {
return "", errInvalidPath
}
return localize(path)
}
|