arfile.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. #if APT_PKG_ABI >= 413
  50. unsigned long long Start;
  51. #else
  52. unsigned long Start;
  53. #endif
  54. Member *Next;
  55. Member() : Start(0), Next(0) {};
  56. };
  57. #endif