osfs

package module
v1.20240116.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 16, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

View Source
var OsRootFS fs.FS = OsFS{}

Functions

This section is empty.

Types

type OsFS

type OsFS struct {
}

func (OsFS) Open

func (f OsFS) Open(fs_name string) (fs.File, error)
Example (Unix)
package main

import (
	"errors"
	"fmt"

	"github.com/l4go/osfs"
)

func main() {
	var err error
	_, err = osfs.OsRootFS.Open("/")
	fmt.Println(errors.Unwrap(err))
	_, err = osfs.OsRootFS.Open(".")
	fmt.Println(err == nil)
	_, err = osfs.OsRootFS.Open("etc/hosts")
	fmt.Println(err == nil)
}
Output:

invalid argument
true
true

func (OsFS) ReadDir

func (f OsFS) ReadDir(fs_name string) ([]fs.DirEntry, error)
Example (Unix)
package main

import (
	"errors"
	"fmt"
	"io/fs"

	"github.com/l4go/osfs"
)

func main() {
	var err error
	_, err = fs.ReadDir(osfs.OsRootFS, "/")
	fmt.Println(errors.Unwrap(err))
	_, err = fs.ReadDir(osfs.OsRootFS, ".")
	fmt.Println(err == nil)
	_, err = fs.ReadDir(osfs.OsRootFS, "etc/hosts")
	fmt.Println(err == nil)
}
Output:

invalid argument
true
false

func (OsFS) ReadFile

func (f OsFS) ReadFile(fs_name string) ([]byte, error)
Example (Unix)
package main

import (
	"errors"
	"fmt"
	"io/fs"

	"github.com/l4go/osfs"
)

func main() {
	var err error
	_, err = fs.Stat(osfs.OsRootFS, "/")
	fmt.Println(errors.Unwrap(err))
	_, err = fs.ReadFile(osfs.OsRootFS, ".")
	fmt.Println(err == nil)
	_, err = fs.ReadFile(osfs.OsRootFS, "etc/hosts")
	fmt.Println(err == nil)
}
Output:

invalid argument
false
true

func (OsFS) Stat

func (f OsFS) Stat(fs_name string) (fs.FileInfo, error)
Example (Unix)
package main

import (
	"errors"
	"fmt"
	"io/fs"

	"github.com/l4go/osfs"
)

func main() {
	var err error
	_, err = fs.Stat(osfs.OsRootFS, "/")
	fmt.Println(errors.Unwrap(err))
	_, err = fs.Stat(osfs.OsRootFS, ".")
	fmt.Println(err == nil)
	_, err = osfs.OsRootFS.Open("etc/hosts")
	fmt.Println(err == nil)
}
Output:

invalid argument
true
true

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL