~ubuntu-branches/ubuntu/vivid/golang/vivid

« back to all changes in this revision

Viewing changes to src/pkg/archive/tar/common.go

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2013-11-27 12:12:43 UTC
  • mfrom: (14.2.6 sid)
  • Revision ID: package-import@ubuntu.com-20131127121243-afpbjphmzzjpctnx
Tags: 2:1.1.2-3ubuntu1
* Merge from Debian unstable.  Remaining changes:
  - 016-armhf-elf-header.patch: Use correct ELF header for armhf binaries.
  - d/control,control.cross: Update Breaks/Replaces for Ubuntu
    versions to ensure smooth upgrades, regenerate control file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
package tar
14
14
 
15
15
import (
 
16
        "bytes"
16
17
        "errors"
17
18
        "fmt"
18
19
        "os"
174
175
        c_ISSOCK = 0140000 // Socket
175
176
)
176
177
 
 
178
// Keywords for the PAX Extended Header
 
179
const (
 
180
        paxAtime    = "atime"
 
181
        paxCharset  = "charset"
 
182
        paxComment  = "comment"
 
183
        paxCtime    = "ctime" // please note that ctime is not a valid pax header.
 
184
        paxGid      = "gid"
 
185
        paxGname    = "gname"
 
186
        paxLinkpath = "linkpath"
 
187
        paxMtime    = "mtime"
 
188
        paxPath     = "path"
 
189
        paxSize     = "size"
 
190
        paxUid      = "uid"
 
191
        paxUname    = "uname"
 
192
        paxNone     = ""
 
193
)
 
194
 
177
195
// FileInfoHeader creates a partially-populated Header from fi.
178
196
// If fi describes a symlink, FileInfoHeader records link as the link target.
179
197
// If fi describes a directory, a slash is appended to the name.
257
275
        b, *sp = s[0:n], s[n:]
258
276
        return
259
277
}
 
278
 
 
279
func isASCII(s string) bool {
 
280
        for _, c := range s {
 
281
                if c >= 0x80 {
 
282
                        return false
 
283
                }
 
284
        }
 
285
        return true
 
286
}
 
287
 
 
288
func toASCII(s string) string {
 
289
        if isASCII(s) {
 
290
                return s
 
291
        }
 
292
        var buf bytes.Buffer
 
293
        for _, c := range s {
 
294
                if c < 0x80 {
 
295
                        buf.WriteByte(byte(c))
 
296
                }
 
297
        }
 
298
        return buf.String()
 
299
}