Skip to content

Commit

Permalink
fix(vfs): relative path (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
DVKunion authored Feb 14, 2023
1 parent 803ea8c commit c2cdcf0
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion go/pkg/vfs/vfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,42 @@ func rootfs() string {
if v := os.Getenv("LIBVEINMIND_HOST_ROOTFS"); v != "" {
return v
} else {
return "/"
return ""
}
}

func Open(name string) (*os.File, error) {
if path, err := filepath.Abs(name); err == nil {
name = path
}
return os.Open(filepath.Join(rootfs(), name))
}

func Stat(name string) (os.FileInfo, error) {
if path, err := filepath.Abs(name); err == nil {
name = path
}
return os.Stat(filepath.Join(rootfs(), name))
}

func Lstat(name string) (os.FileInfo, error) {
if path, err := filepath.Abs(name); err == nil {
name = path
}
return os.Lstat(filepath.Join(rootfs(), name))
}

func Readlink(name string) (string, error) {
if path, err := filepath.Abs(name); err == nil {
name = path
}
return os.Readlink(filepath.Join(rootfs(), name))
}

func Readdir(name string) ([]os.DirEntry, error) {
if path, err := filepath.Abs(name); err == nil {
name = path
}
return os.ReadDir(filepath.Join(rootfs(), name))
}

Expand Down

0 comments on commit c2cdcf0

Please sign in to comment.