fileio

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2025 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const DownloadCacheImportFolder = "import"

Variables

This section is empty.

Functions

func CreateFile

func CreateFile(path string) (*os.File, error)

func ExportPack

func ExportPack(pack core.Pack, fileName string, targetPath string) error

func GetPackwizCache

func GetPackwizCache() (string, error)

func GetPackwizInstallBinFile

func GetPackwizInstallBinFile() (string, error)

func GetPackwizInstallBinPath

func GetPackwizInstallBinPath() (string, error)

func GetPackwizLocalCache

func GetPackwizLocalCache() (string, error)

func GetPackwizLocalStore

func GetPackwizLocalStore() (string, error)

func InitIndexFile

func InitIndexFile(pack core.PackToml) error

func LoadAll

func LoadAll(packPath string) (*core.Pack, error)

func LoadAllMods

func LoadAllMods(index *core.IndexFS) ([]*core.ModToml, error)

func LoadIndex

func LoadIndex(indexFile string) (core.IndexFS, error)

LoadIndex attempts to load the index file from a path

func LoadMod

func LoadMod(modFile string) (core.ModToml, error)

LoadMod attempts to load a mod file from a path

func LoadPackFile

func LoadPackFile(packPath string) (core.PackToml, error)

LoadPackFile loads the modpack metadata to a PackToml struct

func LoadPackIndexFile

func LoadPackIndexFile(pack *core.PackToml) (core.IndexFS, error)

func RefreshIndexFiles

func RefreshIndexFiles(index *core.IndexFS) error

RefreshIndexFiles updates the hashes of all the files in the index, and adds new files to the index

func UpdateIndexFile

func UpdateIndexFile(in *core.IndexFS, path string) error

func WriteAll

func WriteAll(pack core.Pack, targetDir string) error

func WritePackAndIndex

func WritePackAndIndex(pack core.Pack, targetDir string) error

Types

type CacheIndex

type CacheIndex struct {
	Version uint32
	Hashes  map[string][]string
	// contains filtered or unexported fields
}

func (*CacheIndex) GetHandleFromHash

func (c *CacheIndex) GetHandleFromHash(hashFormat string, hash string) *CacheIndexHandle

func (*CacheIndex) GetHandleFromHashForce

func (c *CacheIndex) GetHandleFromHashForce(hashFormat string, hash string) (*CacheIndexHandle, error)

GetHandleFromHashForce looks up the given hash in the index; but will rehash any file without this hash format to obtain the necessary hash. Only use this for manually downloaded files, as it can rehash every file in the cache, which can be more time-consuming than just redownloading the file and noticing it is already in the index!

func (*CacheIndex) MoveImportFiles

func (c *CacheIndex) MoveImportFiles() error

func (*CacheIndex) NewHandleFromHashes

func (c *CacheIndex) NewHandleFromHashes(hashes map[string]string) (*CacheIndexHandle, bool)

type CacheIndexHandle

type CacheIndexHandle struct {
	Hashes map[string]string
	// contains filtered or unexported fields
}

func (*CacheIndexHandle) CreateFromTemp

func (h *CacheIndexHandle) CreateFromTemp(temp *os.File) (*os.File, error)

func (*CacheIndexHandle) GetRemainingHashes

func (h *CacheIndexHandle) GetRemainingHashes(hashesToObtain []string) []string

func (*CacheIndexHandle) Open

func (h *CacheIndexHandle) Open() (*os.File, error)

func (*CacheIndexHandle) Path

func (h *CacheIndexHandle) Path() string

func (*CacheIndexHandle) Remove

func (h *CacheIndexHandle) Remove()

func (*CacheIndexHandle) UpdateIndex

func (h *CacheIndexHandle) UpdateIndex() (warnings []error)

type CompletedDownload

type CompletedDownload struct {
	// File is only populated when the download is successful; points to the opened cache file
	File *os.File
	Mod  *core.Mod
	// Hashes is only populated when the download is successful; contains all stored hashes of the file
	Hashes map[string]string
	// Error indicates if/why downloading this file failed
	Error error
	// Warnings indicates messages to show to the user regarding this file (download was successful, but had a problem)
	Warnings []error
}

type DownloadSession

type DownloadSession interface {
	GetManualDownloads() []core.ManualDownload
	StartDownloads() chan CompletedDownload
	SaveIndex() error
}

func CreateDownloadSession

func CreateDownloadSession(mods []*core.Mod, hashesToObtain []string) (DownloadSession, error)

type IndexWriter

type IndexWriter struct {
}

func NewIndexWriter

func NewIndexWriter() IndexWriter

func (IndexWriter) Write

func (m IndexWriter) Write(writable Writable) error

type ModWriter

type ModWriter struct {
}

func NewModWriter

func NewModWriter() ModWriter

func (ModWriter) Write

func (m ModWriter) Write(writable Writable) (string, string, error)

type PackWriter

type PackWriter struct {
}

func NewPackWriter

func NewPackWriter() PackWriter

func (PackWriter) Write

func (p PackWriter) Write(writable Writable) error

type Writable

type Writable interface {
	core.HashableObject
	GetFilePath() string
	UpdateHash(format, hash string)
}

Jump to

Keyboard shortcuts

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