Documentation ¶
Overview ¶
Provides functions and data structures for working with memory and disk file systems.
Package sys provides platform-independent interfaces to support webassembly runtime
Index ¶
- Variables
- func SetAuthCommon(auth AuthorizeFunc)
- func SetAuthorize(auth AuthorizeFunc)
- type AuthorizeFunc
- type DiskFS
- func (dfs *DiskFS) CreateDirectory(_ string) error
- func (dfs *DiskFS) GetFileHandler(_, name string) (File, error)
- func (dfs *DiskFS) LoadProgress(progressID string) ([]byte, error)
- func (dfs *DiskFS) MkdirAll(path string, perm os.FileMode) error
- func (dfs *DiskFS) Open(name string) (File, error)
- func (dfs *DiskFS) OpenFile(name string, flag int, perm os.FileMode) (File, error)
- func (dfs *DiskFS) ReadFile(name string) ([]byte, error)
- func (dfs *DiskFS) Remove(name string) error
- func (dfs *DiskFS) RemoveAllDirectories()
- func (dfs *DiskFS) RemoveProgress(progressID string) error
- func (dfs *DiskFS) SaveProgress(progressID string, data []byte, perm fs.FileMode) error
- func (dfs *DiskFS) Stat(name string) (fs.FileInfo, error)
- func (dfs *DiskFS) StoreLogs(key string, data string) error
- func (dfs *DiskFS) WriteFile(name string, data []byte, perm os.FileMode) error
- type FS
- type File
- type KeyPair
- type MemChanFile
- func (f *MemChanFile) Close() error
- func (f *MemChanFile) Read(p []byte) (int, error)
- func (f *MemChanFile) Seek(offset int64, whence int) (ret int64, err error)
- func (f *MemChanFile) Stat() (fs.FileInfo, error)
- func (f *MemChanFile) Sync() error
- func (f *MemChanFile) Write(p []byte) (n int, err error)
- type MemFile
- func (f *MemFile) Close() error
- func (f *MemFile) InitBuffer(size int)
- func (f *MemFile) Read(p []byte) (int, error)
- func (f *MemFile) Seek(offset int64, whence int) (ret int64, err error)
- func (f *MemFile) Stat() (fs.FileInfo, error)
- func (f *MemFile) Sync() error
- func (f *MemFile) Write(p []byte) (n int, err error)
- func (f *MemFile) WriteAt(p []byte, offset int64) (n int, err error)
- type MemFileChanInfo
- func (i *MemFileChanInfo) Info() (fs.FileInfo, error)
- func (i *MemFileChanInfo) IsDir() bool
- func (i *MemFileChanInfo) ModTime() time.Time
- func (i *MemFileChanInfo) Mode() fs.FileMode
- func (i *MemFileChanInfo) Name() string
- func (i *MemFileChanInfo) Size() int64
- func (i *MemFileChanInfo) Sys() interface{}
- func (i *MemFileChanInfo) Type() fs.FileMode
- type MemFileInfo
- func (i *MemFileInfo) Info() (fs.FileInfo, error)
- func (i *MemFileInfo) IsDir() bool
- func (i *MemFileInfo) ModTime() time.Time
- func (i *MemFileInfo) Mode() fs.FileMode
- func (i *MemFileInfo) Name() string
- func (i *MemFileInfo) Size() int64
- func (i *MemFileInfo) Sys() interface{}
- func (i *MemFileInfo) Type() fs.FileMode
- type PipeFile
- type SignFunc
- type VerifyFunc
- type VerifyWithFunc
Constants ¶
This section is empty.
Variables ¶
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 SignWithAuth SignFunc // Verify verify method. it should be initialized on different platform. Verify VerifyFunc // Verify verify method. it should be initialized on different platform. VerifyWith VerifyWithFunc Authorize AuthorizeFunc AuthCommon AuthorizeFunc VerifyEd25519With VerifyWithFunc )
Functions ¶
func SetAuthCommon ¶
func SetAuthCommon(auth AuthorizeFunc)
func SetAuthorize ¶
func SetAuthorize(auth AuthorizeFunc)
SetAuthorize sets the authorize callback function
Types ¶
type AuthorizeFunc ¶
type DiskFS ¶
type DiskFS struct { }
DiskFS implement file system on disk
func (*DiskFS) CreateDirectory ¶
func (*DiskFS) Open ¶
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) Remove ¶
Remove removes the named file or (empty) directory. If there is an error, it will be of type *PathError.
func (*DiskFS) RemoveAllDirectories ¶
func (dfs *DiskFS) RemoveAllDirectories()
func (*DiskFS) RemoveProgress ¶
func (*DiskFS) SaveProgress ¶
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 Stat(name string) (fs.FileInfo, 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 // LoadProgress load progress LoadProgress(progressID string) ([]byte, error) // SaveProgress save progress SaveProgress(progressID string, data []byte, perm fs.FileMode) error // RemoveProgress remove progress RemoveProgress(progressID string) error StoreLogs(key string, data string) error // Create Directory CreateDirectory(dirID string) error // GetFileHandler GetFileHandler(dirID, name string) (File, error) // Remove all created directories(used in download directory) RemoveAllDirectories() }
FS An FS provides access to a hierarchical file system.
type MemChanFile ¶
type MemChanFile struct { Name string Buffer chan []byte // file content Mode fs.FileMode // FileInfo.Mode ModTime time.Time // FileInfo.ModTime ChunkWriteSize int // 0 value means no limit Sys interface{} // FileInfo.Sys ErrChan chan error // contains filtered or unexported fields }
MemChanFile used to read or write file content sequentially through a buffer channel. Not aware of the file size, so it can't seek or truncate.
func (*MemChanFile) Read ¶
func (f *MemChanFile) Read(p []byte) (int, error)
Read reads data from the file through the buffer channel It returns io.EOF when the buffer channel is closed.
- p: file in bytes loaded from the buffer channel
func (*MemChanFile) Seek ¶
func (f *MemChanFile) Seek(offset int64, whence int) (ret int64, err error)
Seek not implemented
func (*MemChanFile) Stat ¶
func (f *MemChanFile) Stat() (fs.FileInfo, error)
Stat returns the file information
func (*MemChanFile) Sync ¶
func (f *MemChanFile) Sync() error
Sync write the data chunk to the buffer channel It writes the data to the buffer channel in chunks of ChunkWriteSize. If ChunkWriteSize is 0, it writes the data as a whole.
func (*MemChanFile) Write ¶
func (f *MemChanFile) Write(p []byte) (n int, err error)
Write writes data to the file through the buffer channel It writes the data to the buffer channel in chunks of ChunkWriteSize. If ChunkWriteSize is 0, it writes the data as a whole.
- p: file in bytes to write to the buffer channel
type MemFile ¶
type MemFile struct { Name string Buffer []byte // file content Mode fs.FileMode // FileInfo.Mode ModTime time.Time // FileInfo.ModTime Sys interface{} // FileInfo.Sys // contains filtered or unexported fields }
MemFile represents a file totally loaded in memory Aware of the file size, so it can seek and truncate.
func (*MemFile) InitBuffer ¶
InitBuffer initializes the buffer with a specific size
type MemFileChanInfo ¶
type MemFileChanInfo struct {
// contains filtered or unexported fields
}
MemFileChanInfo represents file information
func (*MemFileChanInfo) Info ¶
func (i *MemFileChanInfo) Info() (fs.FileInfo, error)
Info returns the file information
func (*MemFileChanInfo) IsDir ¶
func (i *MemFileChanInfo) IsDir() bool
IsDir returns true if the file is a directory
func (*MemFileChanInfo) ModTime ¶
func (i *MemFileChanInfo) ModTime() time.Time
ModTime returns the modification time of the file
func (*MemFileChanInfo) Mode ¶
func (i *MemFileChanInfo) Mode() fs.FileMode
Mode returns the file mode bits
func (*MemFileChanInfo) Name ¶
func (i *MemFileChanInfo) Name() string
Name returns the base name of the file
func (*MemFileChanInfo) Sys ¶
func (i *MemFileChanInfo) Sys() interface{}
Sys returns the underlying data source (can return nil)
func (*MemFileChanInfo) Type ¶
func (i *MemFileChanInfo) Type() fs.FileMode
Type returns the file mode type
type MemFileInfo ¶
type MemFileInfo struct {
// contains filtered or unexported fields
}
MemFileInfo represents file information
func (*MemFileInfo) Info ¶
func (i *MemFileInfo) Info() (fs.FileInfo, error)
Info returns the file information
func (*MemFileInfo) IsDir ¶
func (i *MemFileInfo) IsDir() bool
IsDir returns true if the file is a directory
func (*MemFileInfo) ModTime ¶
func (i *MemFileInfo) ModTime() time.Time
ModTime returns the modification time of the file
func (*MemFileInfo) Name ¶
func (i *MemFileInfo) Name() string
Name returns the base name of the file
func (*MemFileInfo) Sys ¶
func (i *MemFileInfo) Sys() interface{}
Sys returns the underlying data source (can return nil)
type PipeFile ¶
type PipeFile struct {
// contains filtered or unexported fields
}
wrapper over io pipe to implement File interface
func NewPipeFile ¶
func NewPipeFile() *PipeFile