diff options
author | Michael Vogt <michael.vogt@ubuntu.com> | 2010-09-07 09:32:51 +0200 |
---|---|---|
committer | Michael Vogt <michael.vogt@ubuntu.com> | 2010-09-07 09:32:51 +0200 |
commit | 3580e481e0dcbb4a39d687137eafcda60d8e85d5 (patch) | |
tree | cacd09d1c987a06d6e02581eb8c3afaf1e56ec00 /apt-pkg/contrib/fileutl.cc | |
parent | debca0004bc8b57e487a5a8ffdec51b54ae2f22a (diff) | |
parent | ca07950ec545b41a18cbeff0ec0ba43624592c07 (diff) |
merged from the debian-sid branch
Diffstat (limited to 'apt-pkg/contrib/fileutl.cc')
-rw-r--r-- | apt-pkg/contrib/fileutl.cc | 21 |
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 |