[Aptitude-svn-commit] r4354 - in branches/aptitude-0.3/aptitude: . src/generic/util

Daniel Burrows dburrows at costa.debian.org
Fri Sep 30 01:36:37 UTC 2005


Author: dburrows
Date: Fri Sep 30 01:36:34 2005
New Revision: 4354

Modified:
   branches/aptitude-0.3/aptitude/ChangeLog
   branches/aptitude-0.3/aptitude/src/generic/util/temp.h
Log:
Support extracting the parent directory of a temporary object.

Modified: branches/aptitude-0.3/aptitude/ChangeLog
==============================================================================
--- branches/aptitude-0.3/aptitude/ChangeLog	(original)
+++ branches/aptitude-0.3/aptitude/ChangeLog	Fri Sep 30 01:36:34 2005
@@ -1,5 +1,10 @@
 2005-09-29  Daniel Burrows  <dburrows at debian.org>
 
+	* src/generic/util/temp.h:
+
+	  Allow clients to extract the parent directory of temporary
+	  objects.
+
 	* src/cmdline/cmdline_do_action.cc:
 
 	  Fix a nasty bug: when constructing the download manager in

Modified: branches/aptitude-0.3/aptitude/src/generic/util/temp.h
==============================================================================
--- branches/aptitude-0.3/aptitude/src/generic/util/temp.h	(original)
+++ branches/aptitude-0.3/aptitude/src/generic/util/temp.h	Fri Sep 30 01:36:34 2005
@@ -89,6 +89,11 @@
      */
     std::string get_name() const;
 
+    /** \return the parent of this directory, or an invalid reference
+     *  if it has none.
+     */
+    dir get_parent() const;
+
     ~dir();
   };
 
@@ -147,6 +152,14 @@
       return dirname;
     }
 
+    /** \return the parent directory of this temporary directory, if
+     *  any.  If none, an invalid reference is returned.
+     */
+    dir get_parent() const
+    {
+      return dir;
+    }
+
     /** Increment the reference count of this impl. */
     void incref()
     {
@@ -207,6 +220,11 @@
     return real_dir->get_name();
   }
 
+  inline dir dir::get_parent() const
+  {
+    return real_dir->get_parent();
+  }
+
   inline dir::~dir()
   {
     if(real_dir != NULL)
@@ -248,6 +266,10 @@
 
     bool valid() const;
     std::string get_name() const;
+    /** \return the enclosing directory of this temporary name; will
+     *          never be an invalid reference unless this is invalid.
+     */
+    std::string get_parent() const;
   };
 
   class name::impl
@@ -284,6 +306,11 @@
       return filename;
     }
 
+    dir get_parent() const
+    {
+      return parent;
+    }
+
     /** Increment the reference count of this impl. */
     void incref()
     {
@@ -349,6 +376,14 @@
   {
     return real_name->get_name();
   }
+
+  inline dir name::get_parent() const
+  {
+    if(real_name != NULL)
+      return real_name->get_parent();
+    else
+      return dir();
+  }
 };
 
 #endif // TEMP_H



More information about the Aptitude-svn-commit mailing list