filesystem

package
v0.0.0-...-79996cc Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2023 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BinMagic            = "DOODLE"
	BinVersion    uint8 = 1 // version of the file format we support
	BinLevelType  uint8 = 1
	BinDoodadType uint8 = 2
)

Binary file format headers for Levels and Doodads.

The header is 8 bytes long: "DOODLE" + file format version + file type number.

Variables

View Source
var (
	SystemDoodadsPath    = filepath.Join("assets", "doodads")
	SystemLevelsPath     = filepath.Join("assets", "levels")
	SystemCampaignsPath  = filepath.Join("assets", "campaigns")
	SystemLevelPacksPath = filepath.Join("assets", "levelpacks")
)

Paths to system-level assets bundled with the application.

Functions

func FindFile

func FindFile(filename string) (string, error)

FindFile looks for a file (level or doodad) in a few places.

The filename should already have a ".level" or ".doodad" file extension. If neither is given, the exact filename will be searched in all places.

1. Check in the files built into the program binary. 2. Check for system files in the binary's assets/ folder. 3. Check the user folders.

Returns the file path and an error if not found anywhere.

func FindFileEmbedded

func FindFileEmbedded(filename string, em Embeddable) (string, error)

FindFileEmbedded searches for a file in a Level or Doodad's embedded filesystem, before searching other places (as FindFile does) -- system paths and user paths.

func MakeHeader

func MakeHeader(filetype uint8) []byte

MakeHeader creates the binary file header.

func ReadHeader

func ReadHeader(filetype uint8, fh io.Reader) error

ReadHeader reads and verifies a header from a filehandle.

Types

type Embeddable

type Embeddable interface {
	GetFile(string) ([]byte, error)
}

Embeddable file formats such as Levels or Doodads.

Jump to

Keyboard shortcuts

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