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 ++-- apt-pkg/contrib/fileutl.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'apt-pkg/contrib') 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; diff --git a/apt-pkg/contrib/fileutl.h b/apt-pkg/contrib/fileutl.h index f79c9032f..419506273 100644 --- a/apt-pkg/contrib/fileutl.h +++ b/apt-pkg/contrib/fileutl.h @@ -101,7 +101,7 @@ bool CreateDirectory(string const &Parent, string const &Path); * /apt/ will be removed before CreateDirectory call. * \param Path which should exist after (successful) call */ -bool CheckDirectory(string const &Parent, string const &Path); +bool CreateAPTDirectoryIfNeeded(string const &Parent, string const &Path); std::vector GetListOfFilesInDir(string const &Dir, string const &Ext, bool const &SortList, bool const &AllowNoExt=false); -- cgit v1.2.3 From 4d8d8112bb2bdee0f0e3cb46a6677e9fa35d791a Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 28 Sep 2010 17:27:44 +0200 Subject: * apt-pkg/contrib/strutl.cc: - add a space between number and unit as required by SI (Closes: #598352) --- apt-pkg/contrib/strutl.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'apt-pkg/contrib') diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc index c1844de40..987f4c3a4 100644 --- a/apt-pkg/contrib/strutl.cc +++ b/apt-pkg/contrib/strutl.cc @@ -340,13 +340,13 @@ string SizeToStr(double Size) { if (ASize < 100 && I != 0) { - sprintf(S,"%'.1f%c",ASize,Ext[I]); + sprintf(S,"%'.1f %c",ASize,Ext[I]); break; } if (ASize < 10000) { - sprintf(S,"%'.0f%c",ASize,Ext[I]); + sprintf(S,"%'.0f %c",ASize,Ext[I]); break; } ASize /= 1000.0; -- cgit v1.2.3 From 9c182afa045dc889a5025d166328c6115924d706 Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Wed, 13 Oct 2010 13:00:49 +0200 Subject: * apt-pkg/contrib/fileutl.cc: - Fix FileFd::Size() for gzipped files to give the size of the uncompressed data. This fixes cache progress building progress going way over 100%. --- apt-pkg/contrib/fileutl.cc | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'apt-pkg/contrib') diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc index eabaadf90..bf07f6008 100644 --- a/apt-pkg/contrib/fileutl.cc +++ b/apt-pkg/contrib/fileutl.cc @@ -915,8 +915,27 @@ unsigned long FileFd::Tell() /* */ unsigned long FileFd::Size() { - //TODO: For gz, do we need the actual file size here or the uncompressed length? struct stat Buf; + long size; + off_t orig_pos; + + if (gz) + { + /* unfortunately zlib.h doesn't provide a gzsize(), so we have to do + * this ourselves; the original (uncompressed) file size is the last 32 + * bits of the file */ + orig_pos = lseek(iFd, 0, SEEK_CUR); + if (lseek(iFd, -4, SEEK_END) < 0) + return _error->Errno("lseek","Unable to seek to end of gzipped file"); + if (read(iFd, &size, 4) != 4) + return _error->Errno("read","Unable to read original size of gzipped file"); + size &= 0xFFFFFFFF; + + if (lseek(iFd, orig_pos, SEEK_SET) < 0) + return _error->Errno("lseek","Unable to seek in gzipped file"); + return size; + } + if (fstat(iFd,&Buf) != 0) return _error->Errno("fstat","Unable to determine the file size"); return Buf.st_size; -- cgit v1.2.3