summaryrefslogtreecommitdiff
path: root/apt-pkg/contrib/fileutl.cc
diff options
context:
space:
mode:
authorMichael Vogt <mvo@debian.org>2010-09-06 18:11:49 +0200
committerMichael Vogt <mvo@debian.org>2010-09-06 18:11:49 +0200
commitfb031c5598c529b98477c47eac6fe11cae4b1b66 (patch)
treede7908c98e8086a148c423e6edb3d8a6e7455491 /apt-pkg/contrib/fileutl.cc
parenteb1115ef4e84b90189a50c15af4002e4e7306c01 (diff)
parent7753e4684e2b80abbed296b90f47be12b4fce8fc (diff)
merged from lp:~donkult/apt/sid
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..eabaadf90 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;
}
/*}}}*/
+// CreateAPTDirectoryIfNeeded - 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 CreateAPTDirectoryIfNeeded(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