Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1349)

Delta Between Two Patch Sets: src/pkg/archive/tar/common.go

Issue 6700047: code review 6700047: archive/tar: read/write extended pax/gnu tar archives (Closed)
Left Patch Set: diff -r 93dc7f0e302b https://code.google.com/p/go Created 11 years, 4 months ago
Right Patch Set: diff -r 439cb8bad388 https://code.google.com/p/go Created 11 years, 1 month ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | src/pkg/archive/tar/reader.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 // Copyright 2009 The Go Authors. All rights reserved. 1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 // Package tar implements access to tar archives. 5 // Package tar implements access to tar archives.
6 // It aims to cover most of the variations, including those produced 6 // It aims to cover most of the variations, including those produced
7 // by GNU and BSD tars. 7 // by GNU and BSD tars.
8 // 8 //
9 // References: 9 // References:
10 // http://www.freebsd.org/cgi/man.cgi?query=tar&sektion=5 10 // http://www.freebsd.org/cgi/man.cgi?query=tar&sektion=5
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 Typeflag byte // type of header entry 50 Typeflag byte // type of header entry
51 Linkname string // target name of link 51 Linkname string // target name of link
52 Uname string // user name of owner 52 Uname string // user name of owner
53 Gname string // group name of owner 53 Gname string // group name of owner
54 Devmajor int64 // major number of character or block device 54 Devmajor int64 // major number of character or block device
55 Devminor int64 // minor number of character or block device 55 Devminor int64 // minor number of character or block device
56 AccessTime time.Time // access time 56 AccessTime time.Time // access time
57 ChangeTime time.Time // status change time 57 ChangeTime time.Time // status change time
58 } 58 }
59 59
60 // File name constants from the tar spec.
61 const (
62 fileNameSize = 100 // Maximum number of bytes in a standard tar na me.
63 fileNamePrefixSize = 155 // Maximum number of ustar extension bytes.
64 )
65
60 // sysStat, if non-nil, populates h from system-dependent fields of fi. 66 // sysStat, if non-nil, populates h from system-dependent fields of fi.
61 var sysStat func(fi os.FileInfo, h *Header) error 67 var sysStat func(fi os.FileInfo, h *Header) error
62 68
63 // Mode constants from the tar spec. 69 // Mode constants from the tar spec.
64 const ( 70 const (
65 c_ISDIR = 040000 71 c_ISDIR = 040000
66 c_ISFIFO = 010000 72 c_ISFIFO = 010000
67 c_ISREG = 0100000 73 c_ISREG = 0100000
68 c_ISLNK = 0120000 74 c_ISLNK = 0120000
69 c_ISBLK = 060000 75 c_ISBLK = 060000
70 c_ISCHR = 020000 76 c_ISCHR = 020000
71 c_ISSOCK = 0140000 77 c_ISSOCK = 0140000
72 ) 78 )
73 79
74 // FileInfoHeader creates a partially-populated Header from fi. 80 // FileInfoHeader creates a partially-populated Header from fi.
75 // If fi describes a symlink, FileInfoHeader records link as the link target. 81 // If fi describes a symlink, FileInfoHeader records link as the link target.
76 func FileInfoHeader(fi os.FileInfo, link string) (*Header, error) { 82 func FileInfoHeader(fi os.FileInfo, link string) (*Header, error) {
77 if fi == nil { 83 if fi == nil {
78 return nil, errors.New("tar: FileInfo is nil") 84 return nil, errors.New("tar: FileInfo is nil")
79 } 85 }
80 h := &Header{ 86 h := &Header{
81 Name: fi.Name(), 87 Name: fi.Name(),
82 ModTime: fi.ModTime(), 88 ModTime: fi.ModTime(),
83 Mode: int64(fi.Mode().Perm()), // or'd with c_IS* constants l ater 89 Mode: int64(fi.Mode().Perm()), // or'd with c_IS* constants l ater
84 } 90 }
85 switch { 91 switch {
86 » case fi.Mode()&os.ModeType == 0: 92 » case fi.Mode().IsRegular():
87 h.Mode |= c_ISREG 93 h.Mode |= c_ISREG
88 h.Typeflag = TypeReg 94 h.Typeflag = TypeReg
89 h.Size = fi.Size() 95 h.Size = fi.Size()
90 case fi.IsDir(): 96 case fi.IsDir():
91 h.Typeflag = TypeDir 97 h.Typeflag = TypeDir
92 h.Mode |= c_ISDIR 98 h.Mode |= c_ISDIR
93 case fi.Mode()&os.ModeSymlink != 0: 99 case fi.Mode()&os.ModeSymlink != 0:
94 h.Typeflag = TypeSymlink 100 h.Typeflag = TypeSymlink
95 h.Mode |= c_ISLNK 101 h.Mode |= c_ISLNK
96 h.Linkname = link 102 h.Linkname = link
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 return 138 return
133 } 139 }
134 140
135 type slicer []byte 141 type slicer []byte
136 142
137 func (sp *slicer) next(n int) (b []byte) { 143 func (sp *slicer) next(n int) (b []byte) {
138 s := *sp 144 s := *sp
139 b, *sp = s[0:n], s[n:] 145 b, *sp = s[0:n], s[n:]
140 return 146 return
141 } 147 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b