gopls modernize
This commit is contained in:
@@ -179,9 +179,10 @@ func (f *File) initializeReaders() error {
|
|||||||
|
|
||||||
func (f *File) deviceDevices() (maj uint32, min uint32) {
|
func (f *File) deviceDevices() (maj uint32, min uint32) {
|
||||||
var dev uint32
|
var dev uint32
|
||||||
if f.b.Inode.Type == inode.Char || f.b.Inode.Type == inode.Block {
|
switch f.b.Inode.Type {
|
||||||
|
case inode.Char, inode.Block:
|
||||||
dev = f.b.Inode.Data.(inode.Device).Dev
|
dev = f.b.Inode.Data.(inode.Device).Dev
|
||||||
} else if f.b.Inode.Type == inode.EChar || f.b.Inode.Type == inode.EBlock {
|
case inode.EChar, inode.EBlock:
|
||||||
dev = f.b.Inode.Data.(inode.EDevice).Dev
|
dev = f.b.Inode.Data.(inode.EDevice).Dev
|
||||||
}
|
}
|
||||||
return dev >> 8, dev & 0x000FF
|
return dev >> 8, dev & 0x000FF
|
||||||
@@ -266,7 +267,7 @@ func (f *File) ExtractWithOptions(path string, op *ExtractionOptions) error {
|
|||||||
}(b, path)
|
}(b, path)
|
||||||
}
|
}
|
||||||
var errCache []error
|
var errCache []error
|
||||||
for i := 0; i < len(d.Entries); i++ {
|
for range d.Entries {
|
||||||
err := <-errChan
|
err := <-errChan
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errCache = append(errCache, err)
|
errCache = append(errCache, err)
|
||||||
@@ -363,11 +364,12 @@ func (f *File) ExtractWithOptions(path string, op *ExtractionOptions) error {
|
|||||||
}
|
}
|
||||||
path = filepath.Join(path, f.b.Name)
|
path = filepath.Join(path, f.b.Name)
|
||||||
var typ string
|
var typ string
|
||||||
if f.b.Inode.Type == inode.Char || f.b.Inode.Type == inode.EChar {
|
switch f.b.Inode.Type {
|
||||||
|
case inode.Char, inode.EChar:
|
||||||
typ = "c"
|
typ = "c"
|
||||||
} else if f.b.Inode.Type == inode.Block || f.b.Inode.Type == inode.EBlock {
|
case inode.Block, inode.EBlock:
|
||||||
typ = "b"
|
typ = "b"
|
||||||
} else { //Fifo IPC
|
default: //Fifo IPC
|
||||||
if runtime.GOOS == "darwin" {
|
if runtime.GOOS == "darwin" {
|
||||||
if op.Verbose {
|
if op.Verbose {
|
||||||
log.Println(f.path(), "ignored. A Fifo file and can't be created on Darwin.")
|
log.Println(f.path(), "ignored. A Fifo file and can't be created on Darwin.")
|
||||||
|
|||||||
+3
-2
@@ -26,9 +26,10 @@ func (r Reader) newFileInfo(e directory.Entry) (fileInfo, error) {
|
|||||||
|
|
||||||
func newFileInfo(name string, i *inode.Inode) fileInfo {
|
func newFileInfo(name string, i *inode.Inode) fileInfo {
|
||||||
var size int64
|
var size int64
|
||||||
if i.Type == inode.Fil {
|
switch i.Type {
|
||||||
|
case inode.Fil:
|
||||||
size = int64(i.Data.(inode.File).Size)
|
size = int64(i.Data.(inode.File).Size)
|
||||||
} else if i.Type == inode.EFil {
|
case inode.EFil:
|
||||||
size = int64(i.Data.(inode.EFile).Size)
|
size = int64(i.Data.(inode.EFile).Size)
|
||||||
}
|
}
|
||||||
return fileInfo{
|
return fileInfo{
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ func (f *FS) Glob(pattern string) (out []string, err error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
split := strings.Split(pattern, "/")
|
split := strings.Split(pattern, "/")
|
||||||
for i := 0; i < len(f.d.Entries); i++ {
|
for i := range f.d.Entries {
|
||||||
if match, _ := path.Match(split[0], f.d.Entries[i].Name); match {
|
if match, _ := path.Match(split[0], f.d.Entries[i].Name); match {
|
||||||
if len(split) == 1 {
|
if len(split) == 1 {
|
||||||
out = append(out, f.d.Entries[i].Name)
|
out = append(out, f.d.Entries[i].Name)
|
||||||
@@ -80,7 +80,7 @@ func (f *FS) Glob(pattern string) (out []string, err error) {
|
|||||||
Err: err,
|
Err: err,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for i := 0; i < len(subGlob); i++ {
|
for i := range subGlob {
|
||||||
subGlob[i] = f.d.Name + "/" + subGlob[i]
|
subGlob[i] = f.d.Name + "/" + subGlob[i]
|
||||||
}
|
}
|
||||||
out = append(out, subGlob...)
|
out = append(out, subGlob...)
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
module github.com/CalebQ42/squashfs
|
module github.com/CalebQ42/squashfs
|
||||||
|
|
||||||
go 1.22.5
|
go 1.24.0
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/klauspost/compress v1.17.9
|
github.com/klauspost/compress v1.18.0
|
||||||
github.com/pierrec/lz4/v4 v4.1.21
|
github.com/pierrec/lz4/v4 v4.1.22
|
||||||
github.com/rasky/go-lzo v0.0.0-20200203143853-96a758eda86e
|
github.com/rasky/go-lzo v0.0.0-20200203143853-96a758eda86e
|
||||||
github.com/therootcompany/xz v1.0.1
|
github.com/therootcompany/xz v1.0.1
|
||||||
github.com/ulikunitz/xz v0.5.12
|
github.com/ulikunitz/xz v0.5.12
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA=
|
github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA=
|
||||||
github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw=
|
github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw=
|
||||||
|
github.com/klauspost/compress v1.18.0 h1:c/Cqfb0r+Yi+JtIEq73FWXVkRonBlf0CRNYc8Zttxdo=
|
||||||
|
github.com/klauspost/compress v1.18.0/go.mod h1:2Pp+KzxcywXVXMr50+X0Q/Lsb43OQHYWRCY2AiWywWQ=
|
||||||
github.com/pierrec/lz4/v4 v4.1.21 h1:yOVMLb6qSIDP67pl/5F7RepeKYu/VmTyEXvuMI5d9mQ=
|
github.com/pierrec/lz4/v4 v4.1.21 h1:yOVMLb6qSIDP67pl/5F7RepeKYu/VmTyEXvuMI5d9mQ=
|
||||||
github.com/pierrec/lz4/v4 v4.1.21/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4=
|
github.com/pierrec/lz4/v4 v4.1.21/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4=
|
||||||
|
github.com/pierrec/lz4/v4 v4.1.22 h1:cKFw6uJDK+/gfw5BcDL0JL5aBsAFdsIT18eRtLj7VIU=
|
||||||
|
github.com/pierrec/lz4/v4 v4.1.22/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4=
|
||||||
github.com/rasky/go-lzo v0.0.0-20200203143853-96a758eda86e h1:dCWirM5F3wMY+cmRda/B1BiPsFtmzXqV9b0hLWtVBMs=
|
github.com/rasky/go-lzo v0.0.0-20200203143853-96a758eda86e h1:dCWirM5F3wMY+cmRda/B1BiPsFtmzXqV9b0hLWtVBMs=
|
||||||
github.com/rasky/go-lzo v0.0.0-20200203143853-96a758eda86e/go.mod h1:9leZcVcItj6m9/CfHY5Em/iBrCz7js8LcRQGTKEEv2M=
|
github.com/rasky/go-lzo v0.0.0-20200203143853-96a758eda86e/go.mod h1:9leZcVcItj6m9/CfHY5Em/iBrCz7js8LcRQGTKEEv2M=
|
||||||
github.com/therootcompany/xz v1.0.1 h1:CmOtsn1CbtmyYiusbfmhmkpAAETj0wBIH6kCYaX+xzw=
|
github.com/therootcompany/xz v1.0.1 h1:CmOtsn1CbtmyYiusbfmhmkpAAETj0wBIH6kCYaX+xzw=
|
||||||
|
|||||||
@@ -50,10 +50,7 @@ func (r *Reader) Read(b []byte) (int, error) {
|
|||||||
return curRead, err
|
return curRead, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
toRead = len(b) - curRead
|
toRead = min(len(b)-curRead, len(r.dat)-int(r.curOffset))
|
||||||
if toRead > len(r.dat)-int(r.curOffset) {
|
|
||||||
toRead = len(r.dat) - int(r.curOffset)
|
|
||||||
}
|
|
||||||
copy(b[curRead:], r.dat[r.curOffset:int(r.curOffset)+toRead])
|
copy(b[curRead:], r.dat[r.curOffset:int(r.curOffset)+toRead])
|
||||||
r.curOffset += uint16(toRead)
|
r.curOffset += uint16(toRead)
|
||||||
curRead += toRead
|
curRead += toRead
|
||||||
|
|||||||
@@ -88,10 +88,7 @@ func (r *FullReader) WriteTo(w io.Writer) (int64, error) {
|
|||||||
var errCache []error
|
var errCache []error
|
||||||
retChan := make(chan *retValue, r.goroutineLimit)
|
retChan := make(chan *retValue, r.goroutineLimit)
|
||||||
for i := uint64(0); i < uint64(math.Ceil(float64(len(r.sizes))/float64(r.goroutineLimit))); i++ {
|
for i := uint64(0); i < uint64(math.Ceil(float64(len(r.sizes))/float64(r.goroutineLimit))); i++ {
|
||||||
toProcess = uint16(len(r.sizes)) - (uint16(i) * r.goroutineLimit)
|
toProcess = min(uint16(len(r.sizes))-(uint16(i)*r.goroutineLimit), r.goroutineLimit)
|
||||||
if toProcess > r.goroutineLimit {
|
|
||||||
toProcess = r.goroutineLimit
|
|
||||||
}
|
|
||||||
// Start all the goroutines
|
// Start all the goroutines
|
||||||
for j := uint16(0); j < toProcess; j++ {
|
for j := uint16(0); j < toProcess; j++ {
|
||||||
go r.process((i*uint64(r.goroutineLimit))+uint64(j), curOffset, retChan)
|
go r.process((i*uint64(r.goroutineLimit))+uint64(j), curOffset, retChan)
|
||||||
|
|||||||
+1
-4
@@ -73,10 +73,7 @@ func (r *Reader) Read(b []byte) (int, error) {
|
|||||||
return curRead, err
|
return curRead, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
toRead = len(b) - curRead
|
toRead = min(len(b)-curRead, len(r.dat)-r.curOffset)
|
||||||
if toRead > len(r.dat)-r.curOffset {
|
|
||||||
toRead = len(r.dat) - r.curOffset
|
|
||||||
}
|
|
||||||
toRead = copy(b[curRead:], r.dat[r.curOffset:r.curOffset+toRead])
|
toRead = copy(b[curRead:], r.dat[r.curOffset:r.curOffset+toRead])
|
||||||
r.curOffset += toRead
|
r.curOffset += toRead
|
||||||
curRead += toRead
|
curRead += toRead
|
||||||
|
|||||||
+2
-8
@@ -105,10 +105,7 @@ func (r *Reader) Id(i uint16) (uint32, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
idsToRead = r.Superblock.IdCount - uint16(len(r.idTable))
|
idsToRead = min(r.Superblock.IdCount-uint16(len(r.idTable)), 2048)
|
||||||
if idsToRead > 2048 {
|
|
||||||
idsToRead = 2048
|
|
||||||
}
|
|
||||||
idsTmp = make([]uint32, idsToRead)
|
idsTmp = make([]uint32, idsToRead)
|
||||||
rdr = metadata.NewReader(toreader.NewReader(r.r, int64(offset)), r.d)
|
rdr = metadata.NewReader(toreader.NewReader(r.r, int64(offset)), r.d)
|
||||||
err = binary.Read(rdr, binary.LittleEndian, &idsTmp)
|
err = binary.Read(rdr, binary.LittleEndian, &idsTmp)
|
||||||
@@ -148,10 +145,7 @@ func (r *Reader) fragEntry(i uint32) (fragEntry, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return fragEntry{}, err
|
return fragEntry{}, err
|
||||||
}
|
}
|
||||||
fragsToRead = r.Superblock.FragCount - uint32(len(r.fragTable))
|
fragsToRead = min(r.Superblock.FragCount-uint32(len(r.fragTable)), 512)
|
||||||
if fragsToRead > 512 {
|
|
||||||
fragsToRead = 512
|
|
||||||
}
|
|
||||||
fragsTmp = make([]fragEntry, fragsToRead)
|
fragsTmp = make([]fragEntry, fragsToRead)
|
||||||
rdr = metadata.NewReader(toreader.NewReader(r.r, int64(offset)), r.d)
|
rdr = metadata.NewReader(toreader.NewReader(r.r, int64(offset)), r.d)
|
||||||
err = binary.Read(rdr, binary.LittleEndian, &fragsTmp)
|
err = binary.Read(rdr, binary.LittleEndian, &fragsTmp)
|
||||||
|
|||||||
Reference in New Issue
Block a user