d2loader

package
v0.0.0-...-7f92c57 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2021 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package d2loader provides a file loader which works in terms of `Source`s and `Asset`s. A `Source` is something that resembles a filesystem, and an `Asset` is something that implements `io.ReadSeeker`.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Loader

type Loader struct {
	d2interface.Cache
	*d2util.Logger
	LoaderProviders map[types.SourceType]func(path string) (asset.Source, error)
	Sources         []asset.Source
	// contains filtered or unexported fields
}

Loader represents the manager that handles loading and caching assets with the asset Sources that have been added

func NewLoader

func NewLoader(l d2util.LogLevel) (*Loader, error)

NewLoader creates a new loader

func (*Loader) AddSource

func (l *Loader) AddSource(path string, sourceType types.SourceType) error

AddSource adds an asset source with the given path. The path will either resolve to a directory or a file on the host filesystem. In the case that it is a file, the file extension is used to determine the type of asset source. In the case that the path points to a directory, a FileSystemSource will be added.

func (*Loader) Exists

func (l *Loader) Exists(subPath string) bool

Exists checks if the given path exists in at least one source

func (*Loader) Load

func (l *Loader) Load(subPath string) (io.ReadSeeker, error)

Load attempts to load an asset with the given sub-path. The sub-path is relative to the root of each asset source root (regardless of the type of asset source)

func (*Loader) SetCharset

func (l *Loader) SetCharset(charset *string)

SetCharset sets the charset for loader

func (*Loader) SetLanguage

func (l *Loader) SetLanguage(language *string)

SetLanguage sets the language for loader

Directories

Path Synopsis
Package asset provides interfaces for Asset and Source
Package asset provides interfaces for Asset and Source
types
Package types provides an enumeration of Asset and Source types, as well as some utility functions
Package types provides an enumeration of Asset and Source types, as well as some utility functions
Package filesystem provides a filesystem Asset and Source implementation for d2loader
Package filesystem provides a filesystem Asset and Source implementation for d2loader
Package mpq provides an MPQ Asset and Source implementation for d2loader
Package mpq provides an MPQ Asset and Source implementation for d2loader

Jump to

Keyboard shortcuts

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