archivefs

package
v0.30.0 Latest Latest
Warning

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

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

Documentation

Overview

Package archivefs allows the traversal of a filetree and treating archive files transparently.

Supported archive formats is currently limited to zip.

Index

Constants

This section is empty.

Variables

View Source
var ArchiveExtensions = [...]string{".ZIP"}

list of file extensions for the supported archive types

Functions

func Open

func Open(filename string) (io.ReadSeeker, int, error)

Open and return an io.ReadSeeker for the specified filename. Filename can be inside an archive supported by archivefs

Returns the io.ReadSeeker, the size of the data behind the ReadSeeker and any errors.

func RemoveArchiveExt

func RemoveArchiveExt(s string) string

RemoveArchiveExt removes the file extension of any supported/recognised archive type from within the string. Only the first instance of the extension is removed

func TrimArchiveExt

func TrimArchiveExt(s string) string

TrimArchiveExt removes the file extension of any supported/recognised archive type from the end of the string

Types

type Node

type Node struct {
	Name string

	// a directory has the the field of IsDir set to true
	IsDir bool

	// a recognised archive file has InArchive set to true. note that an archive
	// file is also considered to be directory
	IsArchive bool
}

Node represents a single part of a full path

func (Node) String

func (e Node) String() string

type Path

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

Path represents a single destination in the file system

func (Path) Base

func (afs Path) Base() string

Base returns the last element of the current path

func (*Path) Close

func (afs *Path) Close()

Close any open zip files and reset path

func (Path) Dir

func (afs Path) Dir() string

Dir returns all but the last element of path

func (Path) InArchive

func (afs Path) InArchive() bool

InArchive returns true if path is currently inside an archive

func (Path) IsDir

func (afs Path) IsDir() bool

IsDir returns true if Path is currently set to a directory. For the purposes of archivefs, the root of an archive is treated as a directory

func (*Path) List

func (afs *Path) List() ([]Node, error)

List returns the child entries for the current path location. If the current path is a file then the list will be the contents of the containing directory of that file

func (Path) Open

func (afs Path) Open() (io.ReadSeeker, int, error)

Open and return an io.ReadSeeker for the filename previously set by the Set() function.

Returns the io.ReadSeeker, the size of the data behind the ReadSeeker and any errors.

func (*Path) Set

func (afs *Path) Set(path string) error

func (Path) String

func (afs Path) String() string

String returns the current path

Jump to

Keyboard shortcuts

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