Fixed a bug in ParseSnapshotData

Added fuction GetSnapshots
pull/7780/head
Thomas Meckel 7 years ago
parent 225a140055
commit 6fd0b3e83e

@ -48,7 +48,7 @@ func ParseSnapshotData(snapshotData string) (*VBoxSnapshot, error) {
parentStack.Push(node)
} else if pathLen < pathLenCur {
currentIndicator = matches[2]
for i := 0; i < pathLenCur-1; i++ {
for i := 0; i < pathLenCur-pathLen; i++ {
parentStack.Pop()
}
}
@ -125,6 +125,21 @@ func (sn *VBoxSnapshot) GetRoot() *VBoxSnapshot {
return node
}
// GetSnapshots returns an array of all snapshots defined
func (sn *VBoxSnapshot) GetSnapshots() []*VBoxSnapshot {
var result []*VBoxSnapshot
root := sn.GetRoot()
ch := walker(root)
for {
node, ok := <-ch
if !ok {
break
}
result = append(result, node)
}
return result
}
// GetSnapshotsByName find all snapshots with a given name
func (sn *VBoxSnapshot) GetSnapshotsByName(name string) []*VBoxSnapshot {
var result []*VBoxSnapshot

Loading…
Cancel
Save