* apt-pkg/cdrom.cc:
[ntk/apt.git] / apt-pkg / cdrom.cc
index 4462d4e..699f66f 100644 (file)
@@ -409,28 +409,12 @@ bool pkgCdrom::WriteDatabase(Configuration &Cnf)
    
    /* Write out all of the configuration directives by walking the
       configuration tree */
-   const Configuration::Item *Top = Cnf.Tree(0);
-   for (; Top != 0;)
-   {
-      // Print the config entry
-      if (Top->Value.empty() == false)
-        Out <<  Top->FullTag() + " \"" << Top->Value << "\";" << endl;
-      
-      if (Top->Child != 0)
-      {
-        Top = Top->Child;
-        continue;
-      }
-      
-      while (Top != 0 && Top->Next == 0)
-        Top = Top->Parent;
-      if (Top != 0)
-        Top = Top->Next;
-   }   
+   Cnf.Dump(Out, NULL, "%f \"%v\";\n", false);
 
    Out.close();
-   
-   link(DFile.c_str(),string(DFile + '~').c_str());
+
+   if (FileExists(DFile) == true)
+      rename(DFile.c_str(), string(DFile + '~').c_str());
    if (rename(NewFile.c_str(),DFile.c_str()) != 0)
       return _error->Errno("rename","Failed to rename %s.new to %s",
                           DFile.c_str(),DFile.c_str());
@@ -697,7 +681,8 @@ bool pkgCdrom::Add(pkgCdromStatus *log)                                     /*{{{*/
       return false;
    }
 
-   chdir(StartDir.c_str());
+   if (chdir(StartDir.c_str()) != 0)
+      return _error->Errno("chdir","Unable to change to %s", StartDir.c_str());
 
    if (_config->FindB("Debug::aptcdrom",false) == true)
    {