Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( //ErrNotDirectory is returned when you're trying to do directory things with a non-directory ErrNotDirectory = errors.New("File is not a directory") //ErrNotFile is returned when you're trying to do file things with a directory ErrNotFile = errors.New("File is not a file") //ErrNotReading is returned when running functions that are only meant to be used when reading a squashfs ErrNotReading = errors.New("Function only supported when reading a squashfs") )
var ( //ErrNoMagic is returned if the magic number in the superblock isn't correct. ErrNoMagic = errors.New("Magic number doesn't match. Either isn't a squashfs or corrupted") //ErrIncompatibleCompression is returned if the compression type in the superblock doesn't work. ErrIncompatibleCompression = errors.New("Compression type unsupported") //ErrCompressorOptions is returned if compressor options is present. It's not currently supported. ErrCompressorOptions = errors.New("Compressor options is not currently supported") )
var ( //ErrNotFound means that the given path is NOT present in the archive ErrNotFound = errors.New("Path not found") )
var ( //ErrPathIsNotFile returns when trying to read from a file, but the given path is NOT a file. ErrPathIsNotFile = errors.New("The given path is not a file") )
Functions ¶
This section is empty.
Types ¶
type File ¶ added in v0.2.0
type File struct { Name string //The name of the file or folder. Root folder will not have a name ("") Parent *File //The parent directory. If it's the root directory, will be nil Reader io.Reader //Underlying reader. When writing, will probably be an os.File. When reading this is kept nil UNTIL reading to save memory. Path string //The path to the folder the File is located in. // contains filtered or unexported fields }
File is the main way to interact with files within squashfs, or when putting files into a squashfs. File can be either a file or folder. When reading from a squashfs, it reads from the datablocks. When writing, this holds the information on WHERE the file will be placed inside the archive.
func (*File) Close ¶ added in v0.2.0
Close frees up the memory held up by the underlying reader. Should NOT be called when writing. When reading, Close is safe to use, but any subsequent Read calls resets to the beginning of the file.
func (*File) GetChildren ¶ added in v0.2.0
GetChildren returns a *squashfs.File slice of every direct child of the directory. If the File is not a directory, will return ErrNotDirectory
func (*File) GetChildrenRecursively ¶ added in v0.2.0
GetChildrenRecursively returns ALL children. Goes down ALL folder paths.
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader processes and reads a squashfs archive. TODO: Give a way to actually read files :P
func NewSquashfsReader ¶
NewSquashfsReader returns a new squashfs.Reader from an io.ReaderAt
func (*Reader) FindAll ¶ added in v0.2.0
FindAll returns all files where the given function returns true.
func (*Reader) FindFile ¶ added in v0.2.0
FindFile returns the first file (in the same order as Reader.GetAllFiles) that the given function returns true for. Returns nil if nothing is found.
func (*Reader) GetAllFiles ¶ added in v0.2.0
GetAllFiles returns a slice of ALL files and folders contained in the squashfs.
func (*Reader) GetFileAtPath ¶ added in v0.2.0
GetFileAtPath will return the file at the given path. If the file cannot be found, will return nil.
func (*Reader) GetRootFolder ¶ added in v0.2.0
GetRootFolder returns a squashfs.File that references the root directory of the squashfs archive.