+18
-11
@@ -26,24 +26,26 @@ var (
|
||||
errNotRelative = errors.New("not a relative path")
|
||||
)
|
||||
|
||||
func WithJunctionsAsDirs() Option {
|
||||
return Option{
|
||||
apply: func(fs Filesystem) {
|
||||
if basic, ok := fs.(*BasicFilesystem); !ok {
|
||||
l.Warnln("WithJunctionsAsDirs must only be used with FilesystemTypeBasic")
|
||||
} else {
|
||||
basic.junctionsAsDirs = true
|
||||
}
|
||||
},
|
||||
id: "junctionsAsDirs",
|
||||
type OptionJunctionsAsDirs struct{}
|
||||
|
||||
func (o *OptionJunctionsAsDirs) apply(fs Filesystem) {
|
||||
if basic, ok := fs.(*BasicFilesystem); !ok {
|
||||
l.Warnln("WithJunctionsAsDirs must only be used with FilesystemTypeBasic")
|
||||
} else {
|
||||
basic.junctionsAsDirs = true
|
||||
}
|
||||
}
|
||||
|
||||
func (o *OptionJunctionsAsDirs) String() string {
|
||||
return "junctionsAsDirs"
|
||||
}
|
||||
|
||||
// The BasicFilesystem implements all aspects by delegating to package os.
|
||||
// All paths are relative to the root and cannot (should not) escape the root directory.
|
||||
type BasicFilesystem struct {
|
||||
root string
|
||||
junctionsAsDirs bool
|
||||
options []Option
|
||||
}
|
||||
|
||||
func newBasicFilesystem(root string, opts ...Option) *BasicFilesystem {
|
||||
@@ -82,7 +84,8 @@ func newBasicFilesystem(root string, opts ...Option) *BasicFilesystem {
|
||||
}
|
||||
|
||||
fs := &BasicFilesystem{
|
||||
root: root,
|
||||
root: root,
|
||||
options: opts,
|
||||
}
|
||||
for _, opt := range opts {
|
||||
opt.apply(fs)
|
||||
@@ -311,6 +314,10 @@ func (f *BasicFilesystem) URI() string {
|
||||
return strings.TrimPrefix(f.root, `\\?\`)
|
||||
}
|
||||
|
||||
func (f *BasicFilesystem) Options() []Option {
|
||||
return f.options
|
||||
}
|
||||
|
||||
func (f *BasicFilesystem) SameFile(fi1, fi2 FileInfo) bool {
|
||||
// Like os.SameFile, we always return false unless fi1 and fi2 were created
|
||||
// by this package's Stat/Lstat method.
|
||||
|
||||
Reference in New Issue
Block a user