arfile.h 1.5 KB

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