v1.13.2
ADDED: * paths.RealPathJoin() and paths.RealPathJoinSys()
This commit is contained in:
parent
772324247a
commit
82f58d4fbf
@ -19,22 +19,23 @@
|
||||
package paths
|
||||
|
||||
import (
|
||||
`context`
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
"os"
|
||||
"os/user"
|
||||
"path"
|
||||
"path/filepath"
|
||||
`sort`
|
||||
"sort"
|
||||
"strings"
|
||||
`sync`
|
||||
`time`
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
// "syscall"
|
||||
|
||||
`github.com/djherbis/times`
|
||||
`r00t2.io/goutils/bitmask`
|
||||
"github.com/djherbis/times"
|
||||
"r00t2.io/goutils/bitmask"
|
||||
)
|
||||
|
||||
/*
|
||||
@ -221,6 +222,68 @@ func RealPath(path *string) (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
/*
|
||||
RealPathJoin combines RealPath with (path).Join.
|
||||
|
||||
If dst is nil, then rootPath will be updated with the new value.
|
||||
You probably don't want that.
|
||||
*/
|
||||
func RealPathJoin(rootPath, dst *string, subPaths ...string) (err error) {
|
||||
|
||||
var newPath string
|
||||
var realDst *string
|
||||
|
||||
if err = RealPath(rootPath); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if dst == nil {
|
||||
realDst = rootPath
|
||||
} else {
|
||||
realDst = dst
|
||||
}
|
||||
|
||||
newPath = path.Join(append([]string{*rootPath}, subPaths...)...)
|
||||
if err = RealPath(&newPath); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
*realDst = newPath
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
/*
|
||||
RealPathJoinSys combines RealPath with (path/filepath).Join.
|
||||
|
||||
If dst is nil, then path will be updated with the new value.
|
||||
You probably don't want that.
|
||||
*/
|
||||
func RealPathJoinSys(path, dst *string, subPaths ...string) (err error) {
|
||||
|
||||
var newPath string
|
||||
var realDst *string
|
||||
|
||||
if err = RealPath(path); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if dst == nil {
|
||||
realDst = path
|
||||
} else {
|
||||
realDst = dst
|
||||
}
|
||||
|
||||
newPath = filepath.Join(append([]string{*path}, subPaths...)...)
|
||||
if err = RealPath(&newPath); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
*realDst = newPath
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
/*
|
||||
RealPathExists is like RealPath, but will also return a boolean as to whether the path
|
||||
actually exists or not.
|
||||
@ -437,10 +500,10 @@ func SearchFsPathsAsync(matcher FsSearchCriteriaAsync) {
|
||||
|
||||
/*
|
||||
filterTimes checks a times.Timespec of a file using:
|
||||
* an age specified by the caller
|
||||
* an ageType bitmask for types of times to compare
|
||||
* an olderThan bool (if false, the file must be younger than)
|
||||
* an optional "now" timestamp for the age derivation.
|
||||
- an age specified by the caller
|
||||
- an ageType bitmask for types of times to compare
|
||||
- an olderThan bool (if false, the file must be younger than)
|
||||
- an optional "now" timestamp for the age derivation.
|
||||
*/
|
||||
func filterTimes(tspec times.Timespec, age *time.Duration, ageType *pathTimeType, olderThan bool, now *time.Time) (include bool) {
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user