summaryrefslogtreecommitdiff
path: root/lib/structure_helpers.go
diff options
context:
space:
mode:
Diffstat (limited to 'lib/structure_helpers.go')
-rw-r--r--lib/structure_helpers.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/structure_helpers.go b/lib/structure_helpers.go
index ac6950a..1b4a6e6 100644
--- a/lib/structure_helpers.go
+++ b/lib/structure_helpers.go
@@ -52,3 +52,30 @@ func FindFirstNonMultipart(bs *models.BodyStructure, path []int) []int {
}
return nil
}
+
+func FindAllNonMultipart(bs *models.BodyStructure, path []int, pathlist [][]int) [][]int {
+ for i, part := range bs.Parts {
+ cur := append(path, i+1)
+ mimetype := strings.ToLower(part.MIMEType)
+ if mimetype != "multipart" {
+ pathlist = append(pathlist, cur)
+ } else if mimetype == "multipart" {
+ if sub := FindAllNonMultipart(part, cur, nil); len(sub) > 0 {
+ pathlist = append(pathlist, sub...)
+ }
+ }
+ }
+ return pathlist
+}
+
+func EqualParts(a []int, b []int) bool {
+ if len(a) != len(b) {
+ return false
+ }
+ for i := 0; i < len(a); i++ {
+ if a[i] != b[i] {
+ return false
+ }
+ }
+ return true
+}