Improved data structure for structs.
Thanks gopls with VS Code
This commit is contained in:
+3
-3
@@ -18,11 +18,11 @@ 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
|
||||||
curReadOffset int //offset relative to the currently cached data
|
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
|
||||||
}
|
}
|
||||||
|
|
||||||
//DataBlock holds info about a given data block from it's size
|
//DataBlock holds info about a given data block from it's size
|
||||||
|
|||||||
@@ -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
@@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user