From e926bb301cd12c8e2779d6b56793b848b2fb84ca Mon Sep 17 00:00:00 2001 From: Clayton Craft Date: Fri, 9 Sep 2022 13:53:37 -0700 Subject: [PATCH] archive: add AddItems method (MR 22) --- pkgs/archive/archive.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pkgs/archive/archive.go b/pkgs/archive/archive.go index f6c0bd3..4254914 100644 --- a/pkgs/archive/archive.go +++ b/pkgs/archive/archive.go @@ -63,6 +63,17 @@ func (archive *Archive) Write(path string, mode os.FileMode) error { return nil } +// Adds the given items in the map to the archive. The map format is {source path:dest path}. +// Internally this just calls AddItem on each key,value pair in the map. +func (archive *Archive) AddItems(paths map[string]string) error { + for s, d := range paths { + if err := archive.AddItem(s, d); err != nil { + return err + } + } + return nil +} + // Adds the given file or directory at "source" to the archive at "dest" func (archive *Archive) AddItem(source string, dest string) error {