merged lp:~donkult/apt/experimental
[ntk/apt.git] / apt-inst / contrib / arfile.h
1 // -*- mode: cpp; mode: fold -*-
2 // Description /*{{{*/
3 // $Id: arfile.h,v 1.2 2001/02/20 07:03:16 jgg Exp $
4 /* ######################################################################
5
6 AR File - Handle an 'AR' archive
7
8 This is a reader for the usual 4.4 BSD AR format. It allows raw
9 stream access to a single member at a time. Basically all this class
10 provides is header parsing and verification. It is up to the client
11 to correctly make use of the stream start/stop points.
12
13 ##################################################################### */
14 /*}}}*/
15 #ifndef PKGLIB_ARFILE_H
16 #define PKGLIB_ARFILE_H
17
18
19 #include <string>
20
21 class FileFd;
22
23 class ARArchive
24 {
25 struct MemberHeader;
26 public:
27 struct Member;
28
29 protected:
30
31 // Linked list of members
32 Member *List;
33
34 bool LoadHeaders();
35
36 public:
37
38 // The stream file
39 FileFd &File;
40
41 // Locate a member by name
42 const Member *FindMember(const char *Name) const;
43 inline Member *Members() { return List; }
44
45 ARArchive(FileFd &File);
46 ~ARArchive();
47 };
48
49 // A member of the archive
50 struct ARArchive::Member
51 {
52 // Fields from the header
53 std::string Name;
54 unsigned long MTime;
55 unsigned long UID;
56 unsigned long GID;
57 unsigned long Mode;
58 unsigned long long Size;
59
60 // Location of the data.
61 unsigned long Start;
62 Member *Next;
63
64 Member() : Start(0), Next(0) {};
65 };
66
67 #endif