sys

package
v1.8.5 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package sys provides platform-independent interfaces to support webassembly runtime

Index

Constants

This section is empty.

Variables

View Source
var (
	//Files file system implementation on sdk. DiskFS doesn't work on webassembly. it should be initialized with common.NewMemFS()
	Files FS = NewDiskFS()

	//Sleep  pauses the current goroutine for at least the duration.
	//  time.Sleep will stop webassembly main thread. it should be bridged to javascript method on webassembly sdk
	Sleep = time.Sleep

	// Sign sign method. it should be initialized on different platform.
	Sign SignFunc
)

Functions

This section is empty.

Types

type DiskFS

type DiskFS struct {
}

DiskFS implement file system on disk

func (*DiskFS) MkdirAll

func (dfs *DiskFS) MkdirAll(path string, perm os.FileMode) error

MkdirAll creates a directory named path

func (*DiskFS) Open

func (dfs *DiskFS) Open(name string) (File, error)

Open opens the named file for reading. If successful, methods on the returned file can be used for reading; the associated file descriptor has mode O_RDONLY. If there is an error, it will be of type *PathError.

func (*DiskFS) OpenFile

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

func (*DiskFS) ReadFile

func (dfs *DiskFS) ReadFile(name string) ([]byte, error)

ReadFile reads the file named by filename and returns the contents.

func (*DiskFS) Remove

func (dfs *DiskFS) Remove(name string) error

Remove removes the named file or (empty) directory. If there is an error, it will be of type *PathError.

func (*DiskFS) WriteFile

func (dfs *DiskFS) WriteFile(name string, data []byte, perm os.FileMode) error

WriteFile writes data to a file named by filename.

type FS

type FS interface {

	// Open opens the named file for reading. If successful, methods on
	// the returned file can be used for reading; the associated file
	// descriptor has mode O_RDONLY.
	// If there is an error, it will be of type *PathError.
	Open(name string) (File, error)

	// OpenFile open a file
	OpenFile(name string, flag int, perm os.FileMode) (File, error)

	// ReadFile reads the file named by filename and returns the contents.
	ReadFile(name string) ([]byte, error)

	// WriteFile writes data to a file named by filename.
	WriteFile(name string, data []byte, perm fs.FileMode) error

	// Remove removes the named file or (empty) directory.
	// If there is an error, it will be of type *PathError.
	Remove(name string) error

	//MkdirAll creates a directory named path
	MkdirAll(path string, perm os.FileMode) error
}

FS An FS provides access to a hierarchical file system.

func NewDiskFS

func NewDiskFS() FS

NewDiskFS create DiskFS instance

func NewMemFS

func NewMemFS() FS

NewMemFS create MemFS instance

type File

type File interface {
	Stat() (fs.FileInfo, error)
	Read([]byte) (int, error)
	Write(p []byte) (n int, err error)

	Sync() error
	Seek(offset int64, whence int) (ret int64, err error)

	Close() error
}

type KeyPair

type KeyPair struct {
	PublicKey  string `json:"public_key"`
	PrivateKey string `json:"private_key"`
}

KeyPair private and publickey

type MemFS

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

MemFS implement file system on memory

func (*MemFS) MkdirAll

func (mfs *MemFS) MkdirAll(path string, perm os.FileMode) error

MkdirAll creates a directory named path

func (*MemFS) Open

func (mfs *MemFS) Open(name string) (File, error)

Open opens the named file for reading. If successful, methods on the returned file can be used for reading; the associated file descriptor has mode O_RDONLY. If there is an error, it will be of type *PathError.

func (*MemFS) OpenFile

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

func (*MemFS) ReadFile

func (mfs *MemFS) ReadFile(name string) ([]byte, error)

ReadFile reads the file named by filename and returns the contents.

func (*MemFS) Remove

func (mfs *MemFS) Remove(name string) error

Remove removes the named file or (empty) directory. If there is an error, it will be of type *PathError.

func (*MemFS) WriteFile

func (mfs *MemFS) WriteFile(name string, data []byte, perm os.FileMode) error

WriteFile writes data to a file named by filename.

type MemFile

type MemFile struct {
	Name    string
	Buffer  *bytes.Buffer // file content
	Mode    fs.FileMode   // FileInfo.Mode
	ModTime time.Time     // FileInfo.ModTime
	Sys     interface{}   // FileInfo.Sys
	// contains filtered or unexported fields
}

func (*MemFile) Close

func (f *MemFile) Close() error

func (*MemFile) Read

func (f *MemFile) Read(p []byte) (int, error)

func (*MemFile) Seek

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

func (*MemFile) Stat

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

func (*MemFile) Sync

func (f *MemFile) Sync() error

func (*MemFile) Write

func (f *MemFile) Write(p []byte) (n int, err error)

type MemFileInfo

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

func (*MemFileInfo) Info

func (i *MemFileInfo) Info() (fs.FileInfo, error)

func (*MemFileInfo) IsDir

func (i *MemFileInfo) IsDir() bool

func (*MemFileInfo) ModTime

func (i *MemFileInfo) ModTime() time.Time

func (*MemFileInfo) Mode

func (i *MemFileInfo) Mode() fs.FileMode

func (*MemFileInfo) Name

func (i *MemFileInfo) Name() string

func (*MemFileInfo) Size

func (i *MemFileInfo) Size() int64

func (*MemFileInfo) Sys

func (i *MemFileInfo) Sys() interface{}

func (*MemFileInfo) Type

func (i *MemFileInfo) Type() fs.FileMode

type SignFunc

type SignFunc func(hash string, signatureScheme string, keys []KeyPair) (string, error)

SignFunc sign method for request verification

Jump to

Keyboard shortcuts

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