-
- // Open the source and destintation files
- FileFd From(Path,FileFd::ReadOnly);
- FileFd To(Itm->DestFile,FileFd::WriteEmpty);
+
+ std::vector<APT::Configuration::Compressor> const compressors = APT::Configuration::getCompressors();
+ std::vector<APT::Configuration::Compressor>::const_iterator compressor = compressors.begin();
+ for (; compressor != compressors.end(); ++compressor)
+ if (compressor->Name == Prog)
+ break;
+ if (compressor == compressors.end())
+ return _error->Error("Extraction of file %s requires unknown compressor %s", Path.c_str(), Prog);
+
+ // Open the source and destination files
+ FileFd From;
+ From.Open(Path, FileFd::ReadOnly, *compressor);
+
+ if(From.FileSize() == 0)
+ return _error->Error(_("Empty files can't be valid archives"));
+
+ FileFd To(Itm->DestFile,FileFd::WriteAtomic);