Core: Switch Hashable struct to HashAppend function
Former-commit-id: 2a20eca0e75bf4067d390f4f5e446de78f26799c
This commit is contained in:
@@ -3,8 +3,7 @@
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Core/AbstractHash.hpp>
|
||||
#include <Nazara/Core/Error.hpp>
|
||||
#include <Nazara/Core/ByteArray.hpp>
|
||||
#include <Nazara/Core/Algorithm.hpp>
|
||||
#include <Nazara/Core/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
@@ -18,39 +17,6 @@ namespace Nz
|
||||
{
|
||||
return Nz::ComputeHash(hash, File(filePath));
|
||||
}
|
||||
|
||||
template<>
|
||||
struct Hashable<File>
|
||||
{
|
||||
bool operator()(const Nz::File& originalFile, AbstractHash* hash) const
|
||||
{
|
||||
|
||||
File file(originalFile.GetPath());
|
||||
if (!file.Open(OpenMode_ReadOnly))
|
||||
{
|
||||
NazaraError("Unable to open file");
|
||||
return false;
|
||||
}
|
||||
|
||||
UInt64 remainingSize = file.GetSize();
|
||||
|
||||
char buffer[NAZARA_CORE_FILE_BUFFERSIZE];
|
||||
while (remainingSize > 0)
|
||||
{
|
||||
unsigned int size = static_cast<unsigned int>(std::min(remainingSize, static_cast<UInt64>(NAZARA_CORE_FILE_BUFFERSIZE)));
|
||||
if (file.Read(&buffer[0], sizeof(char), size) != sizeof(char)*size)
|
||||
{
|
||||
NazaraError("Unable to read file");
|
||||
return false;
|
||||
}
|
||||
|
||||
remainingSize -= size;
|
||||
hash->Append(reinterpret_cast<UInt8*>(&buffer[0]), size);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#include <Nazara/Core/DebugOff.hpp>
|
||||
|
||||
Reference in New Issue
Block a user