From ea54214002c09eeb4dd498d97a564471ec9993c5 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 13 Sep 2011 10:09:00 +0200 Subject: reorder includes: add if needed and include it at first --- apt-pkg/contrib/hashes.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'apt-pkg/contrib/hashes.cc') diff --git a/apt-pkg/contrib/hashes.cc b/apt-pkg/contrib/hashes.cc index 4407574fa..9c251e89f 100644 --- a/apt-pkg/contrib/hashes.cc +++ b/apt-pkg/contrib/hashes.cc @@ -11,12 +11,14 @@ ##################################################################### */ /*}}}*/ // Include Files /*{{{*/ +#include + #include #include #include #include -#include +#include #include #include /*}}}*/ -- cgit v1.2.3 From 650faab01603caac04494d54cf6b10a65c00ea13 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 13 Sep 2011 17:46:48 +0200 Subject: Support large files in the complete toolset. Indexes of this size are pretty unlikely for now, but we need it for deb packages which could become bigger than 4GB now (LP: #815895) --- apt-pkg/contrib/hashes.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'apt-pkg/contrib/hashes.cc') diff --git a/apt-pkg/contrib/hashes.cc b/apt-pkg/contrib/hashes.cc index 9c251e89f..fd76bf229 100644 --- a/apt-pkg/contrib/hashes.cc +++ b/apt-pkg/contrib/hashes.cc @@ -108,18 +108,18 @@ string HashString::toStr() const // Hashes::AddFD - Add the contents of the FD /*{{{*/ // --------------------------------------------------------------------- /* */ -bool Hashes::AddFD(int const Fd,unsigned long Size, bool const addMD5, +bool Hashes::AddFD(int const Fd,unsigned long long Size, bool const addMD5, bool const addSHA1, bool const addSHA256, bool const addSHA512) { unsigned char Buf[64*64]; - int Res = 0; + ssize_t Res = 0; int ToEOF = (Size == 0); while (Size != 0 || ToEOF) { - unsigned n = sizeof(Buf); - if (!ToEOF) n = min(Size,(unsigned long)n); + unsigned long long n = sizeof(Buf); + if (!ToEOF) n = min(Size, n); Res = read(Fd,Buf,n); - if (Res < 0 || (!ToEOF && (unsigned) Res != n)) // error, or short read + if (Res < 0 || (!ToEOF && Res != (ssize_t) n)) // error, or short read return false; if (ToEOF && Res == 0) // EOF break; -- cgit v1.2.3 From 8f3ba4e8708cb72be19dacc2af4f601ee5fea292 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Mon, 19 Sep 2011 13:31:29 +0200 Subject: do not pollute namespace in the headers with using (Closes: #500198) --- apt-pkg/contrib/hashes.cc | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'apt-pkg/contrib/hashes.cc') diff --git a/apt-pkg/contrib/hashes.cc b/apt-pkg/contrib/hashes.cc index fd76bf229..05001f042 100644 --- a/apt-pkg/contrib/hashes.cc +++ b/apt-pkg/contrib/hashes.cc @@ -32,20 +32,20 @@ HashString::HashString() { } -HashString::HashString(string Type, string Hash) : Type(Type), Hash(Hash) +HashString::HashString(std::string Type, std::string Hash) : Type(Type), Hash(Hash) { } -HashString::HashString(string StringedHash) /*{{{*/ +HashString::HashString(std::string StringedHash) /*{{{*/ { // legacy: md5sum without "MD5Sum:" prefix - if (StringedHash.find(":") == string::npos && StringedHash.size() == 32) + if (StringedHash.find(":") == std::string::npos && StringedHash.size() == 32) { Type = "MD5Sum"; Hash = StringedHash; return; } - string::size_type pos = StringedHash.find(":"); + std::string::size_type pos = StringedHash.find(":"); Type = StringedHash.substr(0,pos); Hash = StringedHash.substr(pos+1, StringedHash.size() - pos); @@ -53,34 +53,34 @@ HashString::HashString(string StringedHash) /*{{{*/ std::clog << "HashString(string): " << Type << " : " << Hash << std::endl; } /*}}}*/ -bool HashString::VerifyFile(string filename) const /*{{{*/ +bool HashString::VerifyFile(std::string filename) const /*{{{*/ { - string fileHash; + std::string fileHash; FileFd Fd(filename, FileFd::ReadOnly); if(Type == "MD5Sum") { MD5Summation MD5; MD5.AddFD(Fd.Fd(), Fd.Size()); - fileHash = (string)MD5.Result(); + fileHash = (std::string)MD5.Result(); } else if (Type == "SHA1") { SHA1Summation SHA1; SHA1.AddFD(Fd.Fd(), Fd.Size()); - fileHash = (string)SHA1.Result(); + fileHash = (std::string)SHA1.Result(); } else if (Type == "SHA256") { SHA256Summation SHA256; SHA256.AddFD(Fd.Fd(), Fd.Size()); - fileHash = (string)SHA256.Result(); + fileHash = (std::string)SHA256.Result(); } else if (Type == "SHA512") { SHA512Summation SHA512; SHA512.AddFD(Fd.Fd(), Fd.Size()); - fileHash = (string)SHA512.Result(); + fileHash = (std::string)SHA512.Result(); } Fd.Close(); @@ -100,9 +100,9 @@ bool HashString::empty() const return (Type.empty() || Hash.empty()); } -string HashString::toStr() const +std::string HashString::toStr() const { - return Type+string(":")+Hash; + return Type + std::string(":") + Hash; } // Hashes::AddFD - Add the contents of the FD /*{{{*/ @@ -117,7 +117,7 @@ bool Hashes::AddFD(int const Fd,unsigned long long Size, bool const addMD5, while (Size != 0 || ToEOF) { unsigned long long n = sizeof(Buf); - if (!ToEOF) n = min(Size, n); + if (!ToEOF) n = std::min(Size, n); Res = read(Fd,Buf,n); if (Res < 0 || (!ToEOF && Res != (ssize_t) n)) // error, or short read return false; -- cgit v1.2.3