Browse Source

Made it search for the .disk directory too
Author: jgg
Date: 1999-04-07 05:57:04 GMT
Made it search for the .disk directory too

Arch Librarian 22 years ago
parent
commit
22177db995
1 changed files with 16 additions and 6 deletions
  1. 16 6
      cmdline/apt-cdrom.cc

+ 16 - 6
cmdline/apt-cdrom.cc

@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // -*- mode: cpp; mode: fold -*-
 // Description								/*{{{*/
 // Description								/*{{{*/
-// $Id: apt-cdrom.cc,v 1.20 1999/04/03 01:05:25 jgg Exp $
+// $Id: apt-cdrom.cc,v 1.21 1999/04/07 05:57:04 jgg Exp $
 /* ######################################################################
 /* ######################################################################
    
    
    APT CDROM - Tool for handling APT's CDROM database.
    APT CDROM - Tool for handling APT's CDROM database.
@@ -38,7 +38,8 @@
    search that short circuits when it his a package file in the dir.
    search that short circuits when it his a package file in the dir.
    This speeds it up greatly as the majority of the size is in the
    This speeds it up greatly as the majority of the size is in the
    binary-* sub dirs. */
    binary-* sub dirs. */
-bool FindPackages(string CD,vector<string> &List, unsigned int Depth = 0)
+bool FindPackages(string CD,vector<string> &List,string &InfoDir,
+		  unsigned int Depth = 0)
 {
 {
    static ino_t Inodes[9];
    static ino_t Inodes[9];
    if (Depth >= 7)
    if (Depth >= 7)
@@ -63,6 +64,13 @@ bool FindPackages(string CD,vector<string> &List, unsigned int Depth = 0)
 	 return true;
 	 return true;
    }
    }
 
 
+   // Look for a .disk subdirectory
+   if (stat(".disk",&Buf) == 0)
+   {
+      if (InfoDir.empty() == true)
+	 InfoDir = CD + ".disk/";
+   }
+   
    DIR *D = opendir(".");
    DIR *D = opendir(".");
    if (D == 0)
    if (D == 0)
       return _error->Errno("opendir","Unable to read %s",CD.c_str());
       return _error->Errno("opendir","Unable to read %s",CD.c_str());
@@ -97,7 +105,7 @@ bool FindPackages(string CD,vector<string> &List, unsigned int Depth = 0)
       Inodes[Depth] = Buf.st_ino;
       Inodes[Depth] = Buf.st_ino;
 
 
       // Descend
       // Descend
-      if (FindPackages(CD + Dir->d_name,List,Depth+1) == false)
+      if (FindPackages(CD + Dir->d_name,List,InfoDir,Depth+1) == false)
 	 break;
 	 break;
 
 
       if (chdir(CD.c_str()) != 0)
       if (chdir(CD.c_str()) != 0)
@@ -852,7 +860,8 @@ bool DoAdd(CommandLine &)
    // Get the CD structure
    // Get the CD structure
    vector<string> List;
    vector<string> List;
    string StartDir = SafeGetCWD();
    string StartDir = SafeGetCWD();
-   if (FindPackages(CDROM,List) == false)
+   string InfoDir;
+   if (FindPackages(CDROM,List,InfoDir) == false)
    {
    {
       cout << endl;
       cout << endl;
       return false;
       return false;
@@ -883,9 +892,10 @@ bool DoAdd(CommandLine &)
        _config->FindB("APT::CDROM::Rename",false) == true)
        _config->FindB("APT::CDROM::Rename",false) == true)
    {
    {
       // Try to use the CDs label if at all possible
       // Try to use the CDs label if at all possible
-      if (FileExists(CDROM + "/.disk/info") == true)
+      if (InfoDir.empty() == false &&
+	  FileExists(CDROM + InfoDir + "/info") == true)
       {
       {
-	 ifstream F(string(CDROM+ "/.disk/info").c_str());
+	 ifstream F(string(CDROM + InfoDir + "/info").c_str());
 	 if (!F == 0)
 	 if (!F == 0)
 	    getline(F,Name);
 	    getline(F,Name);