Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 01de43a5ae | |||
| 5b29f4d029 |
@@ -1,8 +1,8 @@
|
|||||||
# squashfs (WIP)
|
# squashfs
|
||||||
|
|
||||||
[](https://pkg.go.dev/github.com/CalebQ42/squashfs) [](https://goreportcard.com/report/github.com/CalebQ42/squashfs)
|
[](https://pkg.go.dev/github.com/CalebQ42/squashfs) [](https://goreportcard.com/report/github.com/CalebQ42/squashfs)
|
||||||
|
|
||||||
A PURE Go library to read and write squashfs.
|
A PURE Go library to read squashfs. There is currently no plans to add archive creation support as it will almost always be better to just call `mksquashfs`. I could see some possible use cases, but probably won't spend time on it unless it's requested (open a discussion fi you want this feature).
|
||||||
|
|
||||||
Currently has support for reading squashfs files and extracting files and folders.
|
Currently has support for reading squashfs files and extracting files and folders.
|
||||||
|
|
||||||
|
|||||||
+7
-1
@@ -71,12 +71,18 @@ func (f File) Read(p []byte) (int, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (f File) ReadAt(p []byte, off int64) (int, error) {
|
func (f File) ReadAt(p []byte, off int64) (int, error) {
|
||||||
|
if f.i.Type != inode.Fil && f.i.Type != inode.EFil {
|
||||||
|
return 0, ErrReadNotFile
|
||||||
|
}
|
||||||
return f.fullRdr.ReadAt(p, off)
|
return f.fullRdr.ReadAt(p, off)
|
||||||
}
|
}
|
||||||
|
|
||||||
// WriteTo writes all data from the file to the writer. This is multi-threaded.
|
// WriteTo writes all data from the file to the writer. This is multi-threaded.
|
||||||
// The underlying reader is seperate from the one used with Read and can be reused.
|
// The underlying reader is seperate from the one used with Read and can be reused.
|
||||||
func (f File) WriteTo(w io.Writer) (int64, error) {
|
func (f File) WriteTo(w io.Writer) (int64, error) {
|
||||||
|
if f.i.Type != inode.Fil && f.i.Type != inode.EFil {
|
||||||
|
return 0, ErrReadNotFile
|
||||||
|
}
|
||||||
return f.fullRdr.WriteTo(w)
|
return f.fullRdr.WriteTo(w)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,7 +96,7 @@ func (f *File) Close() error {
|
|||||||
// If n <= 0 all fs.DirEntry's are returned.
|
// If n <= 0 all fs.DirEntry's are returned.
|
||||||
func (f *File) ReadDir(n int) (out []fs.DirEntry, err error) {
|
func (f *File) ReadDir(n int) (out []fs.DirEntry, err error) {
|
||||||
if !f.IsDir() {
|
if !f.IsDir() {
|
||||||
return nil, errors.New("File is not a directory")
|
return nil, errors.New("file is not a directory")
|
||||||
}
|
}
|
||||||
ents, err := f.r.readDirectory(f.i)
|
ents, err := f.r.readDirectory(f.i)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user