ifd_builder: Fixed so will compile.

This commit is contained in:
Dustin Oprea 2018-04-21 00:24:54 -04:00
parent 83c4834547
commit 00a5a5ad5b
2 changed files with 12 additions and 9 deletions

View File

@ -210,7 +210,7 @@ func TestCollect(t *testing.T) {
tree := index.Tree tree := index.Tree
lookup := index.Lookup lookup := index.Lookup
if rootIfd.Offset != DefaultRootIfdOffset { if rootIfd.Offset != DefaultRootIfdExifOffset {
t.Fatalf("Root-IFD not correct: (0x%04d).", rootIfd) t.Fatalf("Root-IFD not correct: (0x%04d).", rootIfd)
} else if rootIfd.Id != 0 { } else if rootIfd.Id != 0 {
t.Fatalf("Root-IFD does not have the right ID: (%d)", rootIfd.Id) t.Fatalf("Root-IFD does not have the right ID: (%d)", rootIfd.Id)

View File

@ -107,7 +107,7 @@ type ifdOffsetIterator struct {
} }
func (ioi *ifdOffsetIterator) Step(size uint32) { func (ioi *ifdOffsetIterator) Step(size uint32) {
ioi.offset += ifdSize ioi.offset += size
} }
func (ioi *ifdOffsetIterator) Offset() uint32 { func (ioi *ifdOffsetIterator) Offset() uint32 {
@ -129,6 +129,7 @@ func (ib *IfdBuilder) calculateTableSize() (size uint32, err error) {
// TODO(dustin): !! Finish. // TODO(dustin): !! Finish.
return 0, nil
} }
// calculateDataSize returns the number of bytes required the offset-based data // calculateDataSize returns the number of bytes required the offset-based data
@ -144,6 +145,7 @@ func (ib *IfdBuilder) calculateDataSize(tableSize uint32) (size uint32, err erro
// TODO(dustin): !! Finish. // TODO(dustin): !! Finish.
return 0, nil
} }
// generateBytes populates the given table and data byte-arrays. `dataOffset` // generateBytes populates the given table and data byte-arrays. `dataOffset`
@ -168,6 +170,7 @@ func (ib *IfdBuilder) generateBytes(dataOffset uint32, ifdTableRaw, ifdDataRaw [
// TODO(dustin): !! Test that the offsets are identical if there are no changes (on principle). // TODO(dustin): !! Test that the offsets are identical if there are no changes (on principle).
return nil
} }
// allocateIfd will produce the two byte-arrays for every IFD and bump the IOI // allocateIfd will produce the two byte-arrays for every IFD and bump the IOI
@ -183,10 +186,10 @@ func (ib *IfdBuilder) allocateIfd(tableSize, dataSize uint32, ioi *ifdOffsetIter
// appropriately so the IFD-build knows where it can calculate its // appropriately so the IFD-build knows where it can calculate its
// offsets from. // offsets from.
tableRaw := make([]byte, tableSize) tableRaw = make([]byte, tableSize)
dataRaw := make([]byte, dataSize) dataRaw = make([]byte, dataSize)
dataOffset := ioi.Offset() + tableSize dataOffset = ioi.Offset() + tableSize
ioi.Step(tableSize + dataSize) ioi.Step(tableSize + dataSize)
return tableRaw, dataRaw, dataOffset, nil return tableRaw, dataRaw, dataOffset, nil
@ -200,9 +203,9 @@ func (ib *IfdBuilder) BuildExif() (new []byte, err error) {
} }
}() }()
b := new(bytes.Buffer) b := bytes.Buffer{}
ioi = &ifdOffsetIterator{ ioi := &ifdOffsetIterator{
offset: DefaultRootIfdExifOffset, offset: DefaultRootIfdExifOffset,
} }
@ -244,8 +247,8 @@ func (ib *IfdBuilder) BuildExif() (new []byte, err error) {
nextIfdOffset := uint32(0) nextIfdOffset := uint32(0)
if ptr != nil { if ptr != nil {
// This might've been iterated by generateBytes(). It'll also point at the // This might've been iterated by `generateBytes()`. It'll also
// next offset that we can install an IFD to. // point at the next offset that we can install an IFD to.
nextIfdOffset = ioi.Offset() nextIfdOffset = ioi.Offset()
} }