Documentation ¶
Index ¶
- Constants
- func CardSize(cardSize uint16) func(*Writer) error
- func DetectMemoryCard(r io.ReaderAt, size int64) (bool, error)
- func Encoding(encoding uint16) func(*Writer) error
- func FlashID(flashID [12]byte) func(*Writer) error
- func FormatTime(formatTime uint64) func(*Writer) error
- type File
- type FileHeader
- type ReadCloser
- type Reader
- type Writer
Examples ¶
Constants ¶
const ( MemoryCard59 uint16 = 4 << iota MemoryCard123 MemoryCard251 MemoryCard507 MemoryCard1019 MemoryCard2043 )
Supported memory card sizes.
const ( EncodingANSI uint16 = iota EncodingSJIS )
Supported memory card encodings.
Variables ¶
This section is empty.
Functions ¶
func DetectMemoryCard ¶
DetectMemoryCard works out if the io.ReaderAt r pointing to the data of size bytes looks sufficiently like a GameCube memory card image.
func FlashID ¶ added in v0.0.6
FlashID sets the 12 byte Flash ID. If the target is an official memory card then this must be set correctly.
func FormatTime ¶ added in v0.0.6
FormatTime overrides the formatting time, which is expressed in seconds since 00:00:00, 1st January 2000. Setting it to 0 stops the serial number from being computed.
Types ¶
type File ¶
type File struct { FileHeader GameCode string MakerCode string // contains filtered or unexported fields }
A File is a single file within a memory card.
type FileHeader ¶
FileHeader describes a file within a memory card.
func (*FileHeader) FileInfo ¶
func (h *FileHeader) FileInfo() fs.FileInfo
FileInfo returns an fs.FileInfo for the FileHeader.
func (*FileHeader) Mode ¶
func (h *FileHeader) Mode() fs.FileMode
Mode returns the permission and mode bits for the FileHeader.
type ReadCloser ¶
type ReadCloser struct { Reader // contains filtered or unexported fields }
A ReadCloser is a Reader that must be closed when no longer needed.
func OpenReader ¶
func OpenReader(name string) (*ReadCloser, error)
OpenReader will open the memory card image specified by name and return a ReadCloser.
func (*ReadCloser) Close ¶
func (rc *ReadCloser) Close() error
Close closes the memory card image, rendering it unusable for I/O.
type Reader ¶
type Reader struct { File []*File FlashID [12]byte CardSize uint16 Encoding uint16 // contains filtered or unexported fields }
A Reader serves content from a memory card image.
type Writer ¶
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/gc" ) func main() { buf := new(bytes.Buffer) w, err := gc.NewWriter(buf) if err != nil { panic(err) } if err := w.Close(); err != nil { panic(err) } fmt.Println(buf.Len()) }
Output: 524288
func NewWriter ¶
NewWriter returns a Writer targeting a new blank memory card which defaults to 59 block capacity, ANSI encoding and an all-zeroes Flash ID.