Lines Matching full:entry
131 // In entryHeader the first entry, the name, is always printed as 16 bytes right-padded.
203 // An Entry is the internal representation of the per-file header information of one entry in the archive.
204 type Entry struct {
213 func (e *Entry) String() string {
223 // readMetadata reads and parses the metadata for the next entry in the archive.
224 func (ar *Archive) readMetadata() *Entry {
232 log.Fatal("file is not an archive: bad entry")
234 entry := new(Entry)
235 entry.name = strings.TrimRight(string(buf[:16]), " ")
236 if len(entry.name) == 0 {
244 log.Fatal("file is not an archive: bad number in entry: ", err)
250 entry.mtime = get(12, 10, 64)
251 entry.uid = int(get(6, 10, 32))
252 entry.gid = int(get(6, 10, 32))
253 entry.mode = os.FileMode(get(8, 8, 32))
254 entry.size = get(10, 10, 64)
255 return entry
258 // scan scans the archive and executes the specified action on each entry.
259 // When action returns, the file offset is at the start of the next entry.
260 func (ar *Archive) scan(action func(*Entry)) {
262 entry := ar.readMetadata()
263 if entry == nil {
266 action(entry)
270 // listEntry prints to standard output a line describing the entry.
271 func listEntry(ar *Archive, entry *Entry, verbose bool) {
273 fmt.Fprintf(stdout, "%s\n", entry)
275 fmt.Fprintf(stdout, "%s\n", entry.name)
279 // output copies the entry to the specified writer.
280 func (ar *Archive) output(entry *Entry, w io.Writer) {
281 n, err := io.Copy(w, io.LimitReader(ar.fd, entry.size))
285 if n != entry.size {
288 if entry.size&1 == 1 {
296 // skip skips the entry without reading it.
297 func (ar *Archive) skip(entry *Entry) {
298 size := entry.size
308 // match reports whether the entry matches the argument list.
310 func (ar *Archive) match(entry *Entry) bool {
315 if entry.name == name {
355 // Format the entry.
376 // startFile writes the archive entry header.
380 log.Fatal("writing entry header: ", err)
385 // endFile writes the archive entry tail (a single byte of padding, if the file size was odd).
449 // Fmt uses runes for its width calculation, but we need bytes in the entry header.
466 func (ar *Archive) printContents(entry *Entry) {
467 if ar.match(entry) {
469 listEntry(ar, entry, false)
471 ar.output(entry, stdout)
473 ar.skip(entry)
479 func (ar *Archive) skipContents(entry *Entry) {
480 ar.skip(entry)
484 func (ar *Archive) tableOfContents(entry *Entry) {
485 if ar.match(entry) {
486 listEntry(ar, entry, verbose)
488 ar.skip(entry)
492 func (ar *Archive) extractContents(entry *Entry) {
493 if ar.match(entry) {
495 listEntry(ar, entry, false)
497 fd, err := os.OpenFile(entry.name, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, entry.mode)
501 ar.output(entry, fd)
504 ar.skip(entry)