-
Notifications
You must be signed in to change notification settings - Fork 0
/
fs_posix.go
47 lines (38 loc) · 873 Bytes
/
fs_posix.go
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package support
import (
"github.com/bitwormhole/afs"
)
// GetPosixFS ...
func GetPosixFS() afs.FS {
platform := &myPosixFS{}
return NewFS(platform)
}
// core
type myPosixFS struct {
core CommonFileSystemCore
}
func (inst *myPosixFS) _Impl() PlatformFileSystem {
return inst
}
func (inst *myPosixFS) GetCommonFileSystem() CommonFileSystem {
return &inst.core
}
func (inst *myPosixFS) NormalizePath(path string) (string, error) {
sep := inst.Separator()
elements := inst.core.PathToElements(path)
elements, err := inst.core.NormalizePathElements(elements)
if err != nil {
return "", err
}
path = inst.core.ElementsToPath(elements, sep, sep)
return path, nil
}
func (inst *myPosixFS) PathSeparator() string {
return ":"
}
func (inst *myPosixFS) Separator() string {
return "/"
}
func (inst *myPosixFS) ListRoots() []string {
return []string{"/"}
}