diff --git a/fmp/fmp_file.go b/fmp/fmp_file.go index 71441eb..f42e97e 100644 --- a/fmp/fmp_file.go +++ b/fmp/fmp_file.go @@ -41,6 +41,7 @@ func OpenFile(path string) (*FmpFile, error) { ctx.numSectors = uint64((ctx.FileSize / sectorSize) - 1) ctx.Sectors = make([]*FmpSector, 0) currentPath := make([]uint64, 0) + ctx.stream.Seek(2*sectorSize, io.SeekStart) for { sector, err := ctx.readSector() @@ -99,7 +100,7 @@ func (ctx *FmpFile) readHeader() error { } func (ctx *FmpFile) readSector() (*FmpSector, error) { - println("------- Reading sector", ctx.currentSectorID) + println("---------- Reading sector", ctx.currentSectorID) buf := make([]byte, sectorHeaderSize) n, err := ctx.stream.Read(buf) diff --git a/fmp/fmp_sector.go b/fmp/fmp_sector.go index bc7d895..05705bd 100644 --- a/fmp/fmp_sector.go +++ b/fmp/fmp_sector.go @@ -1,6 +1,7 @@ package fmp import ( + "encoding/hex" "fmt" "io" ) @@ -10,7 +11,11 @@ func (sect *FmpSector) readChunks() error { panic("chunks already read") } for { - pos := sect.ID*sectorSize - uint64(len(sect.Payload)) + pos := (sect.ID+1)*sectorSize - uint64(len(sect.Payload)) + + if sect.Payload[0] == 0x00 && sect.Payload[1] == 0x00 { + break + } chunk, err := sect.readChunk(sect.Payload) if chunk == nil { @@ -24,7 +29,7 @@ func (sect *FmpSector) readChunks() error { break } if err != nil { - println(string(sect.Payload)) + println(hex.EncodeToString(sect.Payload)) println("break2") return err }