Fixed a bug in ParseSnapshotData
Added fuction GetSnapshots
This commit is contained in:
parent
225a140055
commit
6fd0b3e83e
|
@ -48,7 +48,7 @@ func ParseSnapshotData(snapshotData string) (*VBoxSnapshot, error) {
|
||||||
parentStack.Push(node)
|
parentStack.Push(node)
|
||||||
} else if pathLen < pathLenCur {
|
} else if pathLen < pathLenCur {
|
||||||
currentIndicator = matches[2]
|
currentIndicator = matches[2]
|
||||||
for i := 0; i < pathLenCur-1; i++ {
|
for i := 0; i < pathLenCur-pathLen; i++ {
|
||||||
parentStack.Pop()
|
parentStack.Pop()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -125,6 +125,21 @@ func (sn *VBoxSnapshot) GetRoot() *VBoxSnapshot {
|
||||||
return node
|
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
|
// GetSnapshotsByName find all snapshots with a given name
|
||||||
func (sn *VBoxSnapshot) GetSnapshotsByName(name string) []*VBoxSnapshot {
|
func (sn *VBoxSnapshot) GetSnapshotsByName(name string) []*VBoxSnapshot {
|
||||||
var result []*VBoxSnapshot
|
var result []*VBoxSnapshot
|
||||||
|
|
Loading…
Reference in New Issue