mirror of
https://github.com/garraflavatra/go-fmp.git
synced 2025-06-28 12:35:12 +00:00
Append chunks to file
This commit is contained in:
@ -25,6 +25,7 @@ type FmpFile struct {
|
|||||||
NumSectors uint
|
NumSectors uint
|
||||||
Stream io.ReadSeeker
|
Stream io.ReadSeeker
|
||||||
Sectors []*FmpSector
|
Sectors []*FmpSector
|
||||||
|
Chunks []*FmpChunk
|
||||||
}
|
}
|
||||||
|
|
||||||
type FmpSector struct {
|
type FmpSector struct {
|
||||||
@ -65,6 +66,7 @@ func OpenFile(path string) (*FmpFile, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
ctx.Sectors[i] = sector
|
ctx.Sectors[i] = sector
|
||||||
|
ctx.Chunks = append(ctx.Chunks, sector.Chunks...)
|
||||||
}
|
}
|
||||||
|
|
||||||
return ctx, nil
|
return ctx, nil
|
||||||
@ -130,13 +132,13 @@ func (ctx *FmpFile) readSector() (*FmpSector, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
sector.Chunks = append(sector.Chunks, chunk)
|
|
||||||
if chunk == nil {
|
if chunk == nil {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if chunk.Length == 0 {
|
if chunk.Length == 0 {
|
||||||
panic("chunk length not set")
|
panic("chunk length not set")
|
||||||
}
|
}
|
||||||
|
sector.Chunks = append(sector.Chunks, chunk)
|
||||||
payload = payload[min(chunk.Length, uint32(len(payload))):]
|
payload = payload[min(chunk.Length, uint32(len(payload))):]
|
||||||
if len(payload) == 0 || (len(payload) == 1 && payload[0] == 0x00) {
|
if len(payload) == 0 || (len(payload) == 1 && payload[0] == 0x00) {
|
||||||
break
|
break
|
||||||
|
Reference in New Issue
Block a user