]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/indexfile.cc
headers are for declarations only
[apt.git] / apt-pkg / indexfile.cc
index 33fb48e35fae2dfcdb0a1890e6437c5cc4930cdd..cce17403db97d9ce8cc472a8165f85a7468d2894 100644 (file)
@@ -53,7 +53,7 @@ pkgIndexFile::Type *pkgIndexFile::Type::GetType(const char *Type)
 }
                                                                        /*}}}*/
 pkgIndexFile::pkgIndexFile(bool Trusted) :                             /*{{{*/
-   Trusted(Trusted)
+   d(NULL), Trusted(Trusted)
 {
 }
                                                                        /*}}}*/
@@ -115,8 +115,9 @@ APT_DEPRECATED std::string pkgIndexFile::LanguageCode() {
 // IndexTarget - Constructor                                           /*{{{*/
 IndexTarget::IndexTarget(std::string const &MetaKey, std::string const &ShortDesc,
       std::string const &LongDesc, std::string const &URI, bool const IsOptional,
-      std::map<std::string, std::string> const &Options) :
-   URI(URI), Description(LongDesc), ShortDesc(ShortDesc), MetaKey(MetaKey), IsOptional(IsOptional), Options(Options)
+      bool const KeepCompressed, std::map<std::string, std::string> const &Options) :
+   URI(URI), Description(LongDesc), ShortDesc(ShortDesc), MetaKey(MetaKey),
+   IsOptional(IsOptional), KeepCompressed(KeepCompressed), Options(Options)
 {
 }
                                                                        /*}}}*/
@@ -137,6 +138,18 @@ std::string IndexTarget::Option(OptionKeys const EnumKey) const            /*{{{*/
       APT_CASE(CREATED_BY);
 #undef APT_CASE
       case FILENAME: return _config->FindDir("Dir::State::lists") + URItoFileName(URI);
+      case EXISTING_FILENAME:
+        std::string const filename = Option(FILENAME);
+        std::vector<std::string> const types = APT::Configuration::getCompressionTypes();
+        for (std::vector<std::string>::const_iterator t = types.begin(); t != types.end(); ++t)
+        {
+           if (t->empty())
+              continue;
+           std::string const file = (*t == "uncompressed") ? filename : (filename + "." + *t);
+           if (FileExists(file))
+              return file;
+        }
+        return "";
    }
    std::map<std::string,std::string>::const_iterator const M = Options.find(Key);
    if (M == Options.end())
@@ -160,7 +173,7 @@ std::string IndexTarget::Format(std::string format) const           /*{{{*/
                                                                        /*}}}*/
 
 pkgIndexTargetFile::pkgIndexTargetFile(IndexTarget const &Target, bool const Trusted) :/*{{{*/
-   pkgIndexFile(Trusted), Target(Target)
+   pkgIndexFile(Trusted), d(NULL), Target(Target)
 {
 }
                                                                        /*}}}*/
@@ -215,3 +228,6 @@ bool pkgIndexTargetFile::Exists() const                                     /*{{{*/
    return FileExists(IndexFileName());
 }
                                                                        /*}}}*/
+
+APT_CONST pkgIndexFile::~pkgIndexFile() {}
+APT_CONST pkgIndexTargetFile::~pkgIndexTargetFile() {}