URL
https://opencores.org/ocsvn/openrisc/openrisc/trunk
Subversion Repositories openrisc
[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [libgo/] [go/] [archive/] [tar/] [common.go] - Rev 747
Compare with Previous | Blame | View Log
// Copyright 2009 The Go Authors. All rights reserved.// Use of this source code is governed by a BSD-style// license that can be found in the LICENSE file.// Package tar implements access to tar archives.// It aims to cover most of the variations, including those produced// by GNU and BSD tars.//// References:// http://www.freebsd.org/cgi/man.cgi?query=tar&sektion=5// http://www.gnu.org/software/tar/manual/html_node/Standard.htmlpackage tarimport "time"const (blockSize = 512// TypesTypeReg = '0' // regular fileTypeRegA = '\x00' // regular fileTypeLink = '1' // hard linkTypeSymlink = '2' // symbolic linkTypeChar = '3' // character device nodeTypeBlock = '4' // block device nodeTypeDir = '5' // directoryTypeFifo = '6' // fifo nodeTypeCont = '7' // reservedTypeXHeader = 'x' // extended headerTypeXGlobalHeader = 'g' // global extended header)// A Header represents a single header in a tar archive.// Some fields may not be populated.type Header struct {Name string // name of header file entryMode int64 // permission and mode bitsUid int // user id of ownerGid int // group id of ownerSize int64 // length in bytesModTime time.Time // modified timeTypeflag byte // type of header entryLinkname string // target name of linkUname string // user name of ownerGname string // group name of ownerDevmajor int64 // major number of character or block deviceDevminor int64 // minor number of character or block deviceAccessTime time.Time // access timeChangeTime time.Time // status change time}var zeroBlock = make([]byte, blockSize)// POSIX specifies a sum of the unsigned byte values, but the Sun tar uses signed byte values.// We compute and return both.func checksum(header []byte) (unsigned int64, signed int64) {for i := 0; i < len(header); i++ {if i == 148 {// The chksum field (header[148:156]) is special: it should be treated as space bytes.unsigned += ' ' * 8signed += ' ' * 8i += 7continue}unsigned += int64(header[i])signed += int64(int8(header[i]))}return}type slicer []bytefunc (sp *slicer) next(n int) (b []byte) {s := *spb, *sp = s[0:n], s[n:]return}
