inmem

package
v0.0.0-...-7d62c13 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package inmem is an in-memory file system.

Index

Constants

This section is empty.

Variables

View Source
var ErrFileNotFound = fmt.Errorf("file not found")
View Source
var ErrInvalidArg = fmt.Errorf("invalid argument")

Functions

func SplitPath

func SplitPath(filePath string) ([]string, string)

SplitPath splits a file path into its directory and file name components. The directory path is returned as a slice of strings, where each element is a directory name.

Types

type Entries

type Entries map[string]*File

type FS

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

func New

func New() *FS

New returns a new in-memory file system.

func (*FS) Create

func (f *FS) Create(name string) (*File, error)

func (*FS) MkdirAll

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

MkdirAll creates a directory named path, along with any necessary parents.

func (*FS) Open

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

Open opens the named file.

func (*FS) OpenFile

func (f *FS) OpenFile(name string, flag int, perm os.FileMode) (*File, error)

func (*FS) ReadDir

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

func (*FS) WriteFile

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

WriteFile writes data to a file named by filename.

type File

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

func (*File) Close

func (f *File) Close() error

func (*File) Info

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

Info implements fs.DirEntry.

func (*File) IsDir

func (f *File) IsDir() bool

func (*File) ModTime

func (f *File) ModTime() time.Time

func (*File) Mode

func (f *File) Mode() fs.FileMode

func (*File) Name

func (f *File) Name() string

func (*File) Read

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

func (*File) Size

func (f *File) Size() int64

func (*File) Stat

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

func (*File) Sys

func (f *File) Sys() any

func (*File) Type

func (f *File) Type() fs.FileMode

func (*File) Write

func (f *File) Write(data []byte) (int, error)

Jump to

Keyboard shortcuts

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