github.com/shogo82148/std@v1.22.1-0.20240327122250-4e474527810c/internal/xcoff/ar.go (about) 1 // Copyright 2018 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package xcoff 6 7 import ( 8 "github.com/shogo82148/std/io" 9 ) 10 11 const ( 12 SAIAMAG = 0x8 13 AIAFMAG = "`\n" 14 AIAMAG = "<aiaff>\n" 15 AIAMAGBIG = "<bigaf>\n" 16 17 // Sizeof 18 FL_HSZ_BIG = 0x80 19 AR_HSZ_BIG = 0x70 20 ) 21 22 // Archive represents an open AIX big archive. 23 type Archive struct { 24 ArchiveHeader 25 Members []*Member 26 27 closer io.Closer 28 } 29 30 // ArchiveHeader holds information about a big archive file header 31 type ArchiveHeader struct { 32 magic string 33 } 34 35 // Member represents a member of an AIX big archive. 36 type Member struct { 37 MemberHeader 38 sr *io.SectionReader 39 } 40 41 // MemberHeader holds information about a big archive member 42 type MemberHeader struct { 43 Name string 44 Size uint64 45 } 46 47 // OpenArchive opens the named archive using os.Open and prepares it for use 48 // as an AIX big archive. 49 func OpenArchive(name string) (*Archive, error) 50 51 // Close closes the Archive. 52 // If the Archive was created using NewArchive directly instead of OpenArchive, 53 // Close has no effect. 54 func (a *Archive) Close() error 55 56 // NewArchive creates a new Archive for accessing an AIX big archive in an underlying reader. 57 func NewArchive(r io.ReaderAt) (*Archive, error) 58 59 // GetFile returns the XCOFF file defined by member name. 60 // FIXME: This doesn't work if an archive has two members with the same 61 // name which can occur if an archive has both 32-bits and 64-bits files. 62 func (arch *Archive) GetFile(name string) (*File, error)