]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/clean.cc
merge MultiArch-ABI. We don't support MultiArch yet (as most other tools),
[apt.git] / apt-pkg / clean.cc
index bad824362d63269cde1e0e02e58f59cc70a6065b..629afd7cf2a7849e4b8ff2798a39698e5a0c7019 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: clean.cc,v 1.3 1999/10/03 21:09:27 jgg Exp $
+// $Id: clean.cc,v 1.4 2001/02/20 07:03:17 jgg Exp $
 /* ######################################################################
 
    Clean - Clean out downloaded directories
@@ -8,20 +8,18 @@
    ##################################################################### */
                                                                        /*}}}*/
 // Includes                                                            /*{{{*/
-#ifdef __GNUG__
-#pragma implementation "apt-pkg/clean.h"
-#endif
-
 #include <apt-pkg/clean.h>
 #include <apt-pkg/strutl.h>
 #include <apt-pkg/error.h>
 #include <apt-pkg/configuration.h>
+#include <apt-pkg/aptconfiguration.h>
+
+#include <apti18n.h>    
 
 #include <dirent.h>
 #include <sys/stat.h>
 #include <unistd.h>
                                                                        /*}}}*/
-
 // ArchiveCleaner::Go - Perform smart cleanup of the archive           /*{{{*/
 // ---------------------------------------------------------------------
 /* Scan the directory for files to erase, we check the version information
 bool pkgArchiveCleaner::Go(string Dir,pkgCache &Cache)
 {
    bool CleanInstalled = _config->FindB("APT::Clean-Installed",true);
-   
-   DIR *D = opendir(Dir.c_str());   
+      
+   DIR *D = opendir(Dir.c_str());
    if (D == 0)
-      return _error->Errno("opendir","Unable to read %s",Dir.c_str());
-   
+      return _error->Errno("opendir",_("Unable to read %s"),Dir.c_str());
+
    string StartDir = SafeGetCWD();
    if (chdir(Dir.c_str()) != 0)
    {
       closedir(D);
-      return _error->Errno("chdir","Unable to change to ",Dir.c_str());
+      return _error->Errno("chdir",_("Unable to change to %s"),Dir.c_str());
    }
    
    for (struct dirent *Dir = readdir(D); Dir != 0; Dir = readdir(D))
@@ -52,8 +50,12 @@ bool pkgArchiveCleaner::Go(string Dir,pkgCache &Cache)
 
       struct stat St;
       if (stat(Dir->d_name,&St) != 0)
-        return _error->Errno("stat","Unable to stat %s.",Dir->d_name);
-
+      {
+        chdir(StartDir.c_str());
+        closedir(D);
+        return _error->Errno("stat",_("Unable to stat %s."),Dir->d_name);
+      }
+      
       // Grab the package name
       const char *I = Dir->d_name;
       for (; *I != 0 && *I != '_';I++);
@@ -73,8 +75,11 @@ bool pkgArchiveCleaner::Go(string Dir,pkgCache &Cache)
       for (I = Start; *I != 0 && *I != '.' ;I++);
       if (*I != '.')
         continue;
-      string Arch = DeQuoteString(string(Start,I-Start));
-            
+      string const Arch = DeQuoteString(string(Start,I-Start));
+      
+      if (APT::Configuration::checkArchitecture(Arch) == false)
+        continue;
+      
       // Lookup the package
       pkgCache::PkgIterator P = Cache.FindPkg(Pkg);
       if (P.end() != true)