summaryrefslogtreecommitdiff
path: root/apt-pkg/contrib/fileutl.cc
diff options
context:
space:
mode:
authorDavid Kalnischkies <kalnischkies@gmail.com>2010-09-02 12:47:48 +0200
committerDavid Kalnischkies <kalnischkies@gmail.com>2010-09-02 12:47:48 +0200
commitb29c37128c2c77490f5851158a7631ed107c79fc (patch)
treedd609a58cf2c3810486d0630490f8cb8750341a3 /apt-pkg/contrib/fileutl.cc
parent158fda31be7d4ae1c80a56223faa8d01efc25acc (diff)
* apt-pkg/deb/dpkgpm.cc:
- create Dir::Log if needed to support /var/log as tmpfs or similar, inspired by Thomas Bechtold, thanks! (Closes: #523919, LP: #220239) Easily done by moving a private method from pkgAcquire into the public area of fileutl.cc to be able to use it also in here
Diffstat (limited to 'apt-pkg/contrib/fileutl.cc')
-rw-r--r--apt-pkg/contrib/fileutl.cc21
1 files changed, 21 insertions, 0 deletions
diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc
index 2b73d1424..94d994e8b 100644
--- a/apt-pkg/contrib/fileutl.cc
+++ b/apt-pkg/contrib/fileutl.cc
@@ -251,6 +251,27 @@ bool CreateDirectory(string const &Parent, string const &Path)
return true;
}
/*}}}*/
+// CheckDirectory - ensure that the given directory exists /*{{{*/
+// ---------------------------------------------------------------------
+/* a small wrapper around CreateDirectory to check if it exists and to
+ remove the trailing "/apt/" from the parent directory if needed */
+bool CheckDirectory(string const &Parent, string const &Path)
+{
+ if (DirectoryExists(Path) == true)
+ return true;
+
+ size_t const len = Parent.size();
+ if (len > 5 && Parent.find("/apt/", len - 6, 5) == len - 5)
+ {
+ if (CreateDirectory(Parent.substr(0,len-5), Path) == true)
+ return true;
+ }
+ else if (CreateDirectory(Parent, Path) == true)
+ return true;
+
+ return false;
+}
+ /*}}}*/
// GetListOfFilesInDir - returns a vector of files in the given dir /*{{{*/
// ---------------------------------------------------------------------
/* If an extension is given only files with this extension are included