mirror of
https://github.com/garraflavatra/go-fmp.git
synced 2025-06-27 20:15:11 +00:00
Add error handling for processChunks
This commit is contained in:
@ -52,8 +52,12 @@ func OpenFile(path string) (*FmpFile, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ctx.Sectors = append(ctx.Sectors, sector)
|
ctx.Sectors = append(ctx.Sectors, sector)
|
||||||
|
|
||||||
if sector.ID != 0 {
|
if sector.ID != 0 {
|
||||||
sector.processChunks(ctx.Dictionary, ¤tPath)
|
err = sector.processChunks(ctx.Dictionary, ¤tPath)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
ctx.Chunks = append(ctx.Chunks, sector.Chunks...)
|
ctx.Chunks = append(ctx.Chunks, sector.Chunks...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ func (sect *FmpSector) readChunks() error {
|
|||||||
panic("chunks already read")
|
panic("chunks already read")
|
||||||
}
|
}
|
||||||
for {
|
for {
|
||||||
pos := (sect.ID+2)*sectorSize - uint64(len(sect.Payload))
|
pos := sect.ID*sectorSize - uint64(len(sect.Payload))
|
||||||
|
|
||||||
chunk, err := sect.readChunk(sect.Payload)
|
chunk, err := sect.readChunk(sect.Payload)
|
||||||
if chunk == nil {
|
if chunk == nil {
|
||||||
@ -46,8 +46,12 @@ func (sect *FmpSector) readChunks() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sect *FmpSector) processChunks(dict *FmpDict, currentPath *[]uint64) {
|
func (sect *FmpSector) processChunks(dict *FmpDict, currentPath *[]uint64) error {
|
||||||
sect.readChunks()
|
err := sect.readChunks()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
for _, chunk := range sect.Chunks {
|
for _, chunk := range sect.Chunks {
|
||||||
switch chunk.Type {
|
switch chunk.Type {
|
||||||
case FMP_CHUNK_PATH_PUSH:
|
case FMP_CHUNK_PATH_PUSH:
|
||||||
@ -92,6 +96,7 @@ func (sect *FmpSector) processChunks(dict *FmpDict, currentPath *[]uint64) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sect *FmpSector) readChunk(payload []byte) (*FmpChunk, error) {
|
func (sect *FmpSector) readChunk(payload []byte) (*FmpChunk, error) {
|
||||||
|
Reference in New Issue
Block a user