You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

151 lines
3.2 KiB

  1. // -*- mode: cpp; mode: fold -*-
  2. // Description /*{{{*/
  3. // $Id: writer.h,v 1.3 2001/05/29 04:08:09 jgg Exp $
  4. /* ######################################################################
  5. Writer
  6. The file writer classes. These write various types of output, sources,
  7. packages and contents.
  8. ##################################################################### */
  9. /*}}}*/
  10. #ifndef WRITER_H
  11. #define WRITER_H
  12. #ifdef __GNUG__
  13. #pragma interface "writer.h"
  14. #endif
  15. #include <string>
  16. #include <stdio.h>
  17. #include <iostream>
  18. #include "cachedb.h"
  19. #include "override.h"
  20. #include "apt-ftparchive.h"
  21. using std::string;
  22. using std::cout;
  23. using std::endl;
  24. class FTWScanner
  25. {
  26. protected:
  27. char *TmpExt;
  28. const char *Ext[10];
  29. const char *OriginalPath;
  30. char *RealPath;
  31. bool ErrorPrinted;
  32. // Stuff for the delinker
  33. bool NoLinkAct;
  34. static FTWScanner *Owner;
  35. static int Scanner(const char *File,const struct stat *sb,int Flag);
  36. bool Delink(string &FileName,const char *OriginalPath,
  37. unsigned long &Bytes,struct stat &St);
  38. inline void NewLine(unsigned Priority)
  39. {
  40. if (ErrorPrinted == false && Quiet <= Priority)
  41. {
  42. cout << endl;
  43. ErrorPrinted = true;
  44. }
  45. }
  46. public:
  47. unsigned long DeLinkLimit;
  48. string InternalPrefix;
  49. virtual bool DoPackage(string FileName) = 0;
  50. bool RecursiveScan(string Dir);
  51. bool LoadFileList(string BaseDir,string File);
  52. bool SetExts(string Vals);
  53. FTWScanner();
  54. virtual ~FTWScanner() {delete [] RealPath; delete [] TmpExt;};
  55. };
  56. class PackagesWriter : public FTWScanner
  57. {
  58. Override Over;
  59. CacheDB Db;
  60. public:
  61. // Some flags
  62. bool DoMD5;
  63. bool NoOverride;
  64. bool DoContents;
  65. // General options
  66. string PathPrefix;
  67. string DirStrip;
  68. FILE *Output;
  69. struct CacheDB::Stats &Stats;
  70. inline bool ReadOverride(string File) {return Over.ReadOverride(File);};
  71. virtual bool DoPackage(string FileName);
  72. PackagesWriter(string DB,string Overrides);
  73. virtual ~PackagesWriter() {};
  74. };
  75. class ContentsWriter : public FTWScanner
  76. {
  77. CacheDB Db;
  78. GenContents Gen;
  79. public:
  80. // General options
  81. FILE *Output;
  82. struct CacheDB::Stats &Stats;
  83. string Prefix;
  84. bool DoPackage(string FileName,string Package);
  85. virtual bool DoPackage(string FileName)
  86. {return DoPackage(FileName,string());};
  87. bool ReadFromPkgs(string PkgFile,string PkgCompress);
  88. void Finish() {Gen.Print(Output);};
  89. inline bool ReadyDB(string DB) {return Db.ReadyDB(DB);};
  90. ContentsWriter(string DB);
  91. virtual ~ContentsWriter() {};
  92. };
  93. class SourcesWriter : public FTWScanner
  94. {
  95. Override BOver;
  96. Override SOver;
  97. char *Buffer;
  98. unsigned long BufSize;
  99. public:
  100. bool NoOverride;
  101. // General options
  102. string PathPrefix;
  103. string DirStrip;
  104. FILE *Output;
  105. struct CacheDB::Stats Stats;
  106. /* inline bool ReadBinOverride(string File) {return BOver.ReadOverride(File);};
  107. bool ReadSrcOverride(string File); // {return BOver.ReadOverride(File);};*/
  108. virtual bool DoPackage(string FileName);
  109. SourcesWriter(string BOverrides,string SOverrides);
  110. virtual ~SourcesWriter() {free(Buffer);};
  111. };
  112. #endif