Improved data structure for structs.

Thanks gopls with VS Code
This commit is contained in:
Caleb Gardner
2020-12-28 11:50:56 -06:00
parent 89ec7eb0fb
commit 47c28baf87
4 changed files with 14 additions and 13 deletions
+2 -2
View File
@@ -18,10 +18,10 @@ var (
//DataReader reads data from data blocks. //DataReader reads data from data blocks.
type dataReader struct { type dataReader struct {
r *Reader r *Reader
offset int64 //offset relative to the beginning of the squash file
blocks []dataBlock blocks []dataBlock
curBlock int //Which block in sizes is currently cached
curData []byte curData []byte
offset int64 //offset relative to the beginning of the squash file
curBlock int //Which block in sizes is currently cached
curReadOffset int //offset relative to the currently cached data curReadOffset int //offset relative to the currently cached data
} }
+7 -6
View File
@@ -30,13 +30,14 @@ var (
// //
//Implements os.FileInfo and io.ReadCloser //Implements os.FileInfo and io.ReadCloser
type File struct { type File struct {
Parent *File //The parent directory. Should ALWAYS be a folder. If it's the root directory, will be nil Reader io.Reader
Reader io.Reader //Underlying reader. When writing, will probably be an os.File. When reading this is kept nil UNTIL reading to save memory. Parent *File
name string //The name of the file or folder. Root folder will not have a name ("") r *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. in *inode.Inode
r *Reader //The squashfs.Reader where this file is contained. name string
in *inode.Inode //Underlyting inode when reading. path string
filType int //The file's type, using inode types. filType int //The file's type, using inode types.
} }
//get a File from a directory.entry //get a File from a directory.entry
+1 -1
View File
@@ -16,9 +16,9 @@ type metadata struct {
//MetadataReader is a block reader for metadata. It will automatically read the next block, when it reaches the end of a block. //MetadataReader is a block reader for metadata. It will automatically read the next block, when it reaches the end of a block.
type metadataReader struct { type metadataReader struct {
s *Reader s *Reader
offset int64
headers []*metadata headers []*metadata
data []byte data []byte
offset int64
readOffset int readOffset int
} }
+2 -2
View File
@@ -29,11 +29,11 @@ var (
//Reader processes and reads a squashfs archive. //Reader processes and reads a squashfs archive.
type Reader struct { type Reader struct {
r io.ReaderAt r io.ReaderAt
super superblock
flags superblockFlags
decompressor compression.Decompressor decompressor compression.Decompressor
fragOffsets []uint64 fragOffsets []uint64
idTable []uint32 idTable []uint32
super superblock
flags superblockFlags
} }
//NewSquashfsReader returns a new squashfs.Reader from an io.ReaderAt //NewSquashfsReader returns a new squashfs.Reader from an io.ReaderAt