Add tar.Headers.Winheaders for Windows metadata

This commit is contained in:
John Starks
2016-02-23 12:48:26 -08:00
parent 752c574975
commit 71ac47a42e
3 changed files with 10 additions and 0 deletions
+2
View File
@@ -59,6 +59,7 @@ type Header struct {
AccessTime time.Time // access time
ChangeTime time.Time // status change time
Xattrs map[string]string
Winheaders map[string]string
}
// File name constants from the tar spec.
@@ -192,6 +193,7 @@ const (
paxUid = "uid"
paxUname = "uname"
paxXattr = "SCHILY.xattr."
paxWindows = "MSWINDOWS."
paxNone = ""
)
+5
View File
@@ -314,6 +314,11 @@ func mergePAX(hdr *Header, headers map[string]string) error {
hdr.Xattrs = make(map[string]string)
}
hdr.Xattrs[k[len(paxXattr):]] = v
} else if strings.HasPrefix(k, paxWindows) {
if hdr.Winheaders == nil {
hdr.Winheaders = make(map[string]string)
}
hdr.Winheaders[k[len(paxWindows):]] = v
}
}
}
+3
View File
@@ -268,6 +268,9 @@ func (tw *Writer) writeHeader(hdr *Header, allowPax bool) error {
for k, v := range hdr.Xattrs {
paxHeaders[paxXattr+k] = v
}
for k, v := range hdr.Winheaders {
paxHeaders[paxWindows+k] = v
}
}
if len(paxHeaders) > 0 {