os

package module
v0.0.0-...-7e999b5 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2021 License: MIT Imports: 5 Imported by: 0

README

os

FS wrapper around the "os" package

Documentation

Overview

Package os provides an io.FS that is implemented using the os package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithFlags

func WithFlags(flags int) jsfs.OFOption

WithFlags sets the flags based on package "os" flag values. By default this is O_RDONLY.

Types

type FS

type FS struct{}

FS implemements fs.ReadDirFS/StatFS/ReadFileFS/GlobFS using functions defined in the "os" and "filepath" packages. In addition we support github.com/johnsiilver/fs/OpenFiler to allow for writing files.

func (*FS) Glob

func (f *FS) Glob(pattern string) (matches []string, err error)

Glob implements fs.GlobFS.Glob().

func (*FS) Open

func (f *FS) Open(name string) (fs.File, error)

Open implements fs.FS.Open().

func (*FS) OpenFile

func (f *FS) OpenFile(name string, perms fs.FileMode, options ...jsfs.OFOption) (fs.File, error)

OpenFile opens a file with the set flags and fs.FileMode. If you want to use the fs.File to write, you need to type assert if to *os.File. If Opening a file for

func (*FS) ReadDir

func (f *FS) ReadDir(name string) ([]fs.DirEntry, error)

ReadDir implements fs.ReadDirFS.ReadDir().

func (*FS) ReadFile

func (f *FS) ReadFile(name string) ([]byte, error)

ReadFile implements fs.ReadFileFS.ReadFile().

func (*FS) Stat

func (f *FS) Stat(name string) (fs.FileInfo, error)

Stat implememnts fs.StatFS.Stat().

func (*FS) WriteFile

func (f *FS) WriteFile(name string, content []byte, perm fs.FileMode) error

WriteFile implements jsfs.Writer.WriteFile(). If the file exists this will attempt to write over it.

type File

type File struct {
	// contains filtered or unexported fields
}

File implememnts fs.File.

func (*File) Close

func (f *File) Close() error

func (*File) OSFile

func (f *File) OSFile() *os.File

OSFile returns the underlying *os.File.

func (*File) Read

func (f *File) Read(b []byte) (n int, err error)

func (*File) ReadDir

func (f *File) ReadDir(n int) ([]fs.DirEntry, error)

func (*File) Seek

func (f *File) Seek(offset int64, whence int) (ret int64, err error)

func (*File) Stat

func (f *File) Stat() (fs.FileInfo, error)

func (*File) Write

func (f *File) Write(b []byte) (n int, err error)

Jump to

Keyboard shortcuts

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