Starting on writing the library

Currently just parses the superblock (but that works!)
This commit is contained in:
Caleb Gardner
2020-11-10 05:54:49 -06:00
parent 40541575f8
commit 630e6e0f7c
10 changed files with 2232 additions and 2094 deletions
+24 -3
View File
@@ -1,9 +1,30 @@
package squashfs
import "io"
import (
"encoding/binary"
"io"
)
//Squashfs is a squashfs backed by a reader.
//Squashfs is a squashfs backed by a ReadSeeker.
type Squashfs struct {
rdr *io.Reader //underlyting reader
rdr *io.ReaderAt //underlying reader
super Superblock
}
//NewSquashfs creates a new Squashfs backed by the given reader
func NewSquashfs(reader io.ReaderAt) (*Squashfs, error) {
var superblock Superblock
err := binary.Read(io.NewSectionReader(reader, 0, int64(binary.Size(superblock))), binary.LittleEndian, &superblock)
if err != nil {
return nil, err
}
return &Squashfs{
rdr: &reader,
super: superblock,
}, nil
}
//GetFlags return the SuperblockFlags of the Squashfs
func (s *Squashfs) GetFlags() SuperblockFlags {
return s.super.GetFlags()
}