Index: src/pkg/archive/tar/common.go |
=================================================================== |
--- a/src/pkg/archive/tar/common.go |
+++ b/src/pkg/archive/tar/common.go |
@@ -13,6 +13,7 @@ |
package tar |
import ( |
+ "bytes" |
"errors" |
"fmt" |
"os" |
@@ -174,6 +175,23 @@ |
c_ISSOCK = 0140000 // Socket |
) |
+// Keywords for the PAX Extended Header |
+const ( |
+ paxAtime = "atime" |
+ paxCharset = "charset" |
+ paxComment = "comment" |
+ paxCtime = "ctime" // please note that ctime is not a valid pax header. |
+ paxGid = "gid" |
+ paxGname = "gname" |
+ paxLinkpath = "linkpath" |
+ paxMtime = "mtime" |
+ paxPath = "path" |
+ paxSize = "size" |
+ paxUid = "uid" |
+ paxUname = "uname" |
+ paxNone = "" |
+) |
+ |
// FileInfoHeader creates a partially-populated Header from fi. |
// If fi describes a symlink, FileInfoHeader records link as the link target. |
// If fi describes a directory, a slash is appended to the name. |
@@ -257,3 +275,25 @@ |
b, *sp = s[0:n], s[n:] |
return |
} |
+ |
+func isASCII(s string) bool { |
+ for _, c := range s { |
+ if c >= 0x80 { |
+ return false |
+ } |
+ } |
+ return true |
+} |
+ |
+func toASCII(s string) string { |
+ if isASCII(s) { |
+ return s |
+ } |
+ var buf bytes.Buffer |
+ for _, c := range s { |
+ if c < 0x80 { |
+ buf.WriteByte(byte(c)) |
+ } |
+ } |
+ return buf.String() |
+} |