psx

package module
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2024 License: BSD-3-Clause Imports: 13 Imported by: 0

README

GitHub release Build Status Coverage Status Go Report Card GoDoc Go version Go version

psx

A library for reading and writing Sony PlayStation 1 memory card images.

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func DetectMemoryCard added in v0.0.5

func DetectMemoryCard(r io.ReaderAt, size int64) (bool, error)

DetectMemoryCard works out if the io.ReaderAt r pointing to the data of size bytes looks sufficiently like a PlayStation 1 memory card image.

Types

type File added in v0.0.5

type File struct {
	FileHeader
	CountryCode string
	ProductCode string
	Identifier  string
	// contains filtered or unexported fields
}

A File is a single file within a memory card.

func (*File) Open added in v0.0.5

func (f *File) Open() (fs.File, error)

Open returns an fs.File that provides access to the File's contents. The file is prefixed with a 128 byte header (the directory frame) followed by one or more 8 KiB blocks. Multiple files may be read concurrently.

type FileHeader added in v0.0.5

type FileHeader struct {
	Name     string
	Modified time.Time
	Size     int64
}

FileHeader describes a file within a memory card.

func (*FileHeader) FileInfo added in v0.0.5

func (h *FileHeader) FileInfo() fs.FileInfo

FileInfo returns an fs.FileInfo for the FileHeader.

func (*FileHeader) Mode added in v0.0.5

func (h *FileHeader) Mode() fs.FileMode

Mode returns the permission and mode bits for the FileHeader.

type ReadCloser added in v0.0.5

type ReadCloser struct {
	Reader
	// contains filtered or unexported fields
}

A ReadCloser is a Reader that must be closed when no longer needed.

func OpenReader added in v0.0.5

func OpenReader(name string) (*ReadCloser, error)

OpenReader will open the memory card image specified by name and return a ReadCloser.

func (*ReadCloser) Close added in v0.0.5

func (rc *ReadCloser) Close() error

Close closes the memory card image, rendering it unusable for I/O.

type Reader added in v0.0.5

type Reader struct {
	File []*File
	// contains filtered or unexported fields
}

A Reader serves content from a memory card image.

func NewReader added in v0.0.5

func NewReader(r io.Reader) (*Reader, error)

NewReader returns a new Reader reading from r.

func (*Reader) Open added in v0.0.5

func (r *Reader) Open(name string) (fs.File, error)

Open opens the named file in the memory card image, using the semantics of fs.FS.Open: paths are always slash separated, with no leading / or ../ elements.

type Writer added in v0.0.5

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

A Writer is used for creating a new memory card image with files written to it.

Example
package main

import (
	"bytes"
	"fmt"

	"github.com/bodgit/psx"
)

func main() {
	buf := new(bytes.Buffer)

	w, err := psx.NewWriter(buf)
	if err != nil {
		panic(err)
	}

	if err := w.Close(); err != nil {
		panic(err)
	}

	fmt.Println(buf.Len())
}
Output:

131072

func NewWriter added in v0.0.5

func NewWriter(w io.Writer) (*Writer, error)

NewWriter returns a Writer that will write a new memory card to w.

func (*Writer) Close added in v0.0.5

func (w *Writer) Close() error

Close writes out the memory card to the underlying io.Writer. Any in-flight open memory card files are closed first.

func (*Writer) Create added in v0.0.5

func (w *Writer) Create() (io.WriteCloser, error)

Create returns an io.WriteCloser for writing a new file on the memory card. The file should consist of a 128 byte header followed by one or more 8 KiB blocks as indicated in the header.

Directories

Path Synopsis
internal
xor

Jump to

Keyboard shortcuts

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