ifd_tag_entry.go: Renamed unexported getter to be nicer

for/master
Dustin Oprea 2020-01-11 10:43:06 -05:00
parent 7d26e69f8d
commit fa4e784620
4 changed files with 18 additions and 9 deletions

View File

@ -433,8 +433,8 @@ func Test_IfdByteEncoder_encodeTagToBytes_childIfd__withAllocate(t *testing.T) {
t.Fatalf("IFD first tag type not correct: (%d)", iteV.TagType()) t.Fatalf("IFD first tag type not correct: (%d)", iteV.TagType())
} else if iteV.UnitCount() != 1 { } else if iteV.UnitCount() != 1 {
t.Fatalf("IFD first tag unit-count not correct: (%d)", iteV.UnitCount()) t.Fatalf("IFD first tag unit-count not correct: (%d)", iteV.UnitCount())
} else if iteV.valueOffset_() != nextIfdOffsetToWrite { } else if iteV.getValueOffset() != nextIfdOffsetToWrite {
t.Fatalf("IFD's child-IFD offset (as offset) is not correct: (%d) != (%d)", iteV.valueOffset_(), nextIfdOffsetToWrite) t.Fatalf("IFD's child-IFD offset (as offset) is not correct: (%d) != (%d)", iteV.getValueOffset(), nextIfdOffsetToWrite)
} else if iteV.ChildIfdPath() != exifcommon.IfdPathStandardExif { } else if iteV.ChildIfdPath() != exifcommon.IfdPathStandardExif {
t.Fatalf("IFD first tag IFD-name name not correct: [%s]", iteV.ChildIfdPath()) t.Fatalf("IFD first tag IFD-name name not correct: [%s]", iteV.ChildIfdPath())
} else if iteV.IfdPath() != exifcommon.IfdPathStandard { } else if iteV.IfdPath() != exifcommon.IfdPathStandard {

View File

@ -267,7 +267,7 @@ func (ie *IfdEnumerate) ParseIfd(fqIfdPath string, ifdIndex int, enumerator *Ifd
if doDescend == true { if doDescend == true {
ifdEnumerateLogger.Debugf(nil, "Descending to IFD [%s].", ite.ChildIfdPath()) ifdEnumerateLogger.Debugf(nil, "Descending to IFD [%s].", ite.ChildIfdPath())
err := ie.scan(ite.ChildFqIfdPath(), ite.valueOffset_(), visitor) err := ie.scan(ite.ChildFqIfdPath(), ite.getValueOffset(), visitor)
log.PanicIf(err) log.PanicIf(err)
} }
} }
@ -1032,7 +1032,7 @@ func (ie *IfdEnumerate) Collect(rootIfdOffset uint32) (index IfdIndex, err error
TagId: ite.TagId(), TagId: ite.TagId(),
Index: 0, Index: 0,
Offset: ite.valueOffset_(), Offset: ite.getValueOffset(),
Parent: ifd, Parent: ifd,
ParentTagIndex: i, ParentTagIndex: i,
} }

View File

@ -97,9 +97,10 @@ func (ite *IfdTagEntry) updateUnitCount(unitCount uint32) {
ite.unitCount = unitCount ite.unitCount = unitCount
} }
// valueOffset_ is the four-byte offset converted to an integer to point to the // getValueOffset is the four-byte offset converted to an integer to point to
// location of its value in the EXIF block. // the location of its value in the EXIF block. The "get" parameter is obviously
func (ite *IfdTagEntry) valueOffset_() uint32 { // used in order to differentiate the naming of the method from the field.
func (ite *IfdTagEntry) getValueOffset() uint32 {
return ite.valueOffset return ite.valueOffset
} }

View File

@ -22,7 +22,8 @@ func (Tag927CMakerNote) EncoderName() string {
} }
func (mn Tag927CMakerNote) String() string { func (mn Tag927CMakerNote) String() string {
parts := make([]string, 20) parts := make([]string, len(mn.MakerNoteType))
for i, c := range mn.MakerNoteType { for i, c := range mn.MakerNoteType {
parts[i] = fmt.Sprintf("%02x", c) parts[i] = fmt.Sprintf("%02x", c)
} }
@ -83,8 +84,15 @@ func (Codec927CMakerNote) Decode(valueContext *exifcommon.ValueContext) (value E
// fmt.Printf("ENTRY: 0x%02x %d\n", entry.TagId, entry.TagType) // fmt.Printf("ENTRY: 0x%02x %d\n", entry.TagId, entry.TagType)
// } // }
var makerNoteType []byte
if len(valueBytes) >= 20 {
makerNoteType = valueBytes[:20]
} else {
makerNoteType = valueBytes
}
mn := Tag927CMakerNote{ mn := Tag927CMakerNote{
MakerNoteType: valueBytes[:20], MakerNoteType: makerNoteType,
// MakerNoteBytes has the whole length of bytes. There's always // MakerNoteBytes has the whole length of bytes. There's always
// the chance that the first 20 bytes includes actual data. // the chance that the first 20 bytes includes actual data.