X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/b508453a93fb26354b3f7f9fd828216d1cf4636d..2c384bb626cbaa682c20b94beb14589611847191:/methods/bzip2.cc diff --git a/methods/bzip2.cc b/methods/bzip2.cc index 241f21c66..8e7e46557 100644 --- a/methods/bzip2.cc +++ b/methods/bzip2.cc @@ -13,11 +13,14 @@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include + #include #include #include #include #include +#include #include #include @@ -45,9 +48,9 @@ class Bzip2Method : public pkgAcqMethod bool Bzip2Method::Fetch(FetchItem *Itm) { URI Get = Itm->Uri; - string Path = Get.Host + Get.Path; // To account for relative paths + std::string Path = Get.Host + Get.Path; // To account for relative paths - string GzPathOption = "Dir::bin::"+string(Prog); + std::string GzPathOption = "Dir::bin::" + std::string(Prog); FetchResult Res; Res.Filename = Itm->DestFile; @@ -56,12 +59,8 @@ bool Bzip2Method::Fetch(FetchItem *Itm) // Open the source and destination files FileFd From(Path,FileFd::ReadOnly); - // if the file is empty, just rename it and return - if(From.Size() == 0) - { - rename(Path.c_str(), Itm->DestFile.c_str()); - return true; - } + if(From.FileSize() == 0) + return _error->Error(_("Empty files can't be valid archives")); int GzOut[2]; if (pipe(GzOut) < 0) @@ -80,7 +79,7 @@ bool Bzip2Method::Fetch(FetchItem *Itm) SetCloseExec(STDOUT_FILENO,false); const char *Args[3]; - string Tmp = _config->Find(GzPathOption,Prog); + std::string Tmp = _config->Find(GzPathOption,Prog); Args[0] = Tmp.c_str(); Args[1] = "-d"; Args[2] = 0;