From b29c37128c2c77490f5851158a7631ed107c79fc Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 2 Sep 2010 12:47:48 +0200 Subject: * 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 --- apt-pkg/contrib/fileutl.cc | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'apt-pkg/contrib/fileutl.cc') 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 -- cgit v1.2.3 From 7753e4684e2b80abbed296b90f47be12b4fce8fc Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 6 Sep 2010 14:10:26 +0200 Subject: rename the newly public CheckDirectory method to CreateAPTDirectoryIfNeeded to give a better indication what this method will do if called. --- apt-pkg/contrib/fileutl.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'apt-pkg/contrib/fileutl.cc') diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc index 94d994e8b..eabaadf90 100644 --- a/apt-pkg/contrib/fileutl.cc +++ b/apt-pkg/contrib/fileutl.cc @@ -251,11 +251,11 @@ bool CreateDirectory(string const &Parent, string const &Path) return true; } /*}}}*/ -// CheckDirectory - ensure that the given directory exists /*{{{*/ +// 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 CheckDirectory(string const &Parent, string const &Path) +bool CreateAPTDirectoryIfNeeded(string const &Parent, string const &Path) { if (DirectoryExists(Path) == true) return true; -- cgit v1.2.3