os

package
v0.0.0-...-8e84a60 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2022 License: MIT Imports: 5 Imported by: 4

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 {
	// contains filtered or unexported fields
}

FS is a filesystem tied to the os filesystem implementing:

  • fs.ReadDirFS
  • fs.StatFS
  • fs.ReadFileFS
  • fs.GlobFS

using functions defined in the "os" and "filepath" packages. In addition this supports:

  • gfs.Writer
  • gfs.MkdirAllFS
  • gfs.Remove

Where "gfs" is github.com/gopherfs/fs .

func New

func New(options ...Option) (*FS, error)

New is the constructor for FS.

func (*FS) Glob

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

Glob implements fs.GlobFS.Glob().

func (*FS) Mkdir

func (f *FS) Mkdir(path string, perm fs.FileMode) error

Mkdir implements os.Mkdir().

func (*FS) MkdirAll

func (f *FS) MkdirAll(path string, perm fs.FileMode) error

MkdirAll implements os.MkdirAll().

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) Remove

func (f *FS) Remove(name string) error

Remove implements os.Remove().

func (*FS) RemoveAll

func (f *FS) RemoveAll(path string) error

RemoveAll implements os.RemoveAll().

func (*FS) Stat

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

Stat implememnts fs.StatFS.Stat().

func (*FS) Sub

func (f *FS) Sub(dir string) (fs.FS, error)

Sub implements io/fs.SubFS.

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)

type Option

type Option func(f *FS)

Option is an optional argumetn for FS.

func WithLogger

func WithLogger(l jsfs.Logger) Option

WithLogger adds a custom Logger. Defaults to using the stdlib logger.

Jump to

Keyboard shortcuts

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