vfs

package
v0.20.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2020 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FormatUnknown = iota
	FormatRom
	FormatSnap
	FormatTape
	FormatMax // limit count
)

File formats

View Source
const (
	ExtRom = "rom"
	ExtZip = "zip"
)

Commont extensions

View Source
const (
	PathRom  = "roms"  // ROMs default subpath
	PathSnap = "snaps" // Snapshots default subpath
	PathTape = "tapes" // Tapes default subpath
)

Default subpath constants

Variables

This section is empty.

Functions

func InitDesktop

func InitDesktop()

InitDesktop initialices the desktop filesystem

func SetFileSystem

func SetFileSystem(fs FileSystem)

SetFileSystem returns the current filesystem

Types

type DesktopFileSystem

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

DesktopFileSystem implements the file system for desktop

func NewDesktopFileSystem

func NewDesktopFileSystem(path string) *DesktopFileSystem

NewDesktopFileSystem creates a new desktop filesystem

func (*DesktopFileSystem) LoadFile

func (dfs *DesktopFileSystem) LoadFile(info *FileInfo) error

LoadFile loads the file data from it's storage location.

func (*DesktopFileSystem) SaveFile

func (dfs *DesktopFileSystem) SaveFile(info *FileInfo) error

SaveFile saves fhe file data to it's storage location.

type FileInfo

type FileInfo struct {
	Path   string // File path
	Name   string // File name
	Ext    string // File extension
	Format int    // File format
	IsZip  bool   // Is a zip file
	Data   []byte // File data
}

FileInfo contains file information

func NewFileInfo

func NewFileInfo(path string) *FileInfo

NewFileInfo returns new file info

func NewFileInfoData

func NewFileInfoData(path string, data []byte) *FileInfo

NewFileInfoData returns new file info with data

type FileManager

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

FileManager is the emulator files manager

func NewFileManager

func NewFileManager() *FileManager

NewFileManager returns a new file manager

func (*FileManager) AddFormat

func (manager *FileManager) AddFormat(format int, extension string)

AddFormat adds a file extension format

func (*FileManager) FileInfo added in v0.20.0

func (manager *FileManager) FileInfo(filename string) *FileInfo

FileInfo returns the file information

func (*FileManager) LoadFile

func (manager *FileManager) LoadFile(info *FileInfo) error

LoadFile loads a base filename from its format default location

func (*FileManager) LoadROM

func (manager *FileManager) LoadROM(filename string) ([]byte, error)

LoadROM loads a file from ROMs path

func (*FileManager) NewName

func (manager *FileManager) NewName(prefix, ext string) string

NewName helper funcion to obtain a new filename

func (*FileManager) RegisterFormat

func (manager *FileManager) RegisterFormat(format int, extensions []string)

RegisterFormat adds a format and its extensions

func (*FileManager) SaveFile

func (manager *FileManager) SaveFile(filename string, format int, data []byte) error

SaveFile saves data to a new file

func (*FileManager) SetFileSystem

func (manager *FileManager) SetFileSystem(vfs FileSystem)

SetFileSystem set virtual file system

type FileSystem

type FileSystem interface {
	// LoadFile loads the file data from the storage location.
	LoadFile(info *FileInfo) error
	// SaveFile saves fhe file data to the storage location.
	SaveFile(info *FileInfo) error
}

FileSystem is a virtual filesystem

func GetFileSystem

func GetFileSystem() FileSystem

GetFileSystem returns the current filesystem

type MemFileSystem

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

MemFileSystem is a simple in-memory filesystem

func NewMemFileSystem

func NewMemFileSystem() *MemFileSystem

NewMemFileSystem creates a new in-memory filesystem

func (*MemFileSystem) LoadFile

func (mfs *MemFileSystem) LoadFile(info *FileInfo) error

LoadFile loads the file data from memory

func (*MemFileSystem) SaveFile

func (mfs *MemFileSystem) SaveFile(info *FileInfo) error

SaveFile stores fhe file data into memory

Jump to

Keyboard shortcuts

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