]> git.saurik.com Git - apt.git/blobdiff - cmdline/apt-helper.cc
improve debug output in case downloadfile fails
[apt.git] / cmdline / apt-helper.cc
index d8ea0435ae93b9c30fb8dc26fcad911f54073245..37279ec280711ad8bba3196db5c8a8efe6bc5fb6 100644 (file)
@@ -7,6 +7,7 @@
 // Include Files                                                       /*{{{*/
 #include <config.h>
 
+#include <apt-pkg/configuration.h>
 #include <apt-pkg/cmndline.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/init.h>
 
 #include <apt-private/acqprogress.h>
 #include <apt-private/private-output.h>
+#include <apt-private/private-download.h>
 #include <apt-private/private-cmndline.h>
 
-#include <errno.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/wait.h>
-#include <fcntl.h>
-
-
+#include <iostream>
+#include <string>
+#include <vector>
 
 #include <apti18n.h>
                                                                        /*}}}*/
-using namespace std;
 
 static bool DoDownloadFile(CommandLine &CmdL)
 {
@@ -47,23 +43,22 @@ static bool DoDownloadFile(CommandLine &CmdL)
    new pkgAcqFile(&Fetcher, download_uri, "", 0, "desc", "short-desc", 
                   "dest-dir-ignored", targetfile);
    Fetcher.Run();
-   if (!FileExists(targetfile))
-   {
-      _error->Error(_("Download Failed"));
-      return false;
-   }
+   bool Failed = false;
+   if (AcquireRun(Fetcher, 0, &Failed, NULL) == false || Failed == false ||
+        FileExists(targetfile) == false)
+      return _error->Error(_("Download Failed"));
    return true;
 }
 
-static bool ShowHelp(CommandLine &CmdL)
+static bool ShowHelp(CommandLine &)
 {
-   ioprintf(cout,_("%s %s for %s compiled on %s %s\n"),PACKAGE,PACKAGE_VERSION,
+   ioprintf(std::cout,_("%s %s for %s compiled on %s %s\n"),PACKAGE,PACKAGE_VERSION,
            COMMON_ARCH,__DATE__,__TIME__);
 
    if (_config->FindB("version") == true)
      return true;
 
-   cout << 
+   std::cout <<
     _("Usage: apt-helper [options] command\n"
       "       apt-helper [options] download-file uri target-path\n"
       "\n"