mirror of
https://github.com/garraflavatra/go-fmp.git
synced 2025-06-28 12:35:12 +00:00
Return nil if dict path does not exist
This commit is contained in:
@ -3,6 +3,9 @@ package fmp
|
|||||||
func (ctx *FmpFile) Tables() []*FmpTable {
|
func (ctx *FmpFile) Tables() []*FmpTable {
|
||||||
tables := make([]*FmpTable, 0)
|
tables := make([]*FmpTable, 0)
|
||||||
metaDict := ctx.Dictionary.get([]uint64{4, 1, 7})
|
metaDict := ctx.Dictionary.get([]uint64{4, 1, 7})
|
||||||
|
if metaDict == nil {
|
||||||
|
return tables
|
||||||
|
}
|
||||||
for _, meta := range *metaDict.Children {
|
for _, meta := range *metaDict.Children {
|
||||||
name := decodeByteSeq(meta.Children.get([]uint64{16}).Value)
|
name := decodeByteSeq(meta.Children.get([]uint64{16}).Value)
|
||||||
table := &FmpTable{Name: name}
|
table := &FmpTable{Name: name}
|
||||||
|
@ -47,7 +47,7 @@ func (dict *FmpDict) get(path []uint64) *FmpDictEntry {
|
|||||||
for i, key := range path {
|
for i, key := range path {
|
||||||
_, ok := (*dict)[key]
|
_, ok := (*dict)[key]
|
||||||
if !ok {
|
if !ok {
|
||||||
(*dict)[key] = &FmpDictEntry{Children: &FmpDict{}}
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if i == len(path)-1 {
|
if i == len(path)-1 {
|
||||||
|
Reference in New Issue
Block a user