From 082fb091f1a0cab9d00e82de54fee32b6a1c0c7b Mon Sep 17 00:00:00 2001 From: Benjamin Dobell Date: Sun, 1 Jun 2014 14:09:56 +1000 Subject: Fixed support for large files (up to 2^32 - 1 bytes) The Loke protocol supports 32-bit unsigned for the size of files being flashed. However, POSIX file commands only support 32-bit (signed). As such we now have platform specific support for larger files. --- heimdall/source/FlashAction.cpp | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'heimdall/source/FlashAction.cpp') diff --git a/heimdall/source/FlashAction.cpp b/heimdall/source/FlashAction.cpp index aa08ed8..590e0b5 100644 --- a/heimdall/source/FlashAction.cpp +++ b/heimdall/source/FlashAction.cpp @@ -87,7 +87,7 @@ static bool openFiles(Arguments& arguments, vector& partitionFile if (pitArgument) { - pitFile = fopen(pitArgument->GetValue().c_str(), "rb"); + pitFile = FileOpen(pitArgument->GetValue().c_str(), "rb"); if (!pitFile) { @@ -109,7 +109,7 @@ static bool openFiles(Arguments& arguments, vector& partitionFile if (arguments.GetArgumentTypes().find(argumentName) == arguments.GetArgumentTypes().end()) { const StringArgument *stringArgument = static_cast(*it); - FILE *file = fopen(stringArgument->GetValue().c_str(), "rb"); + FILE *file = FileOpen(stringArgument->GetValue().c_str(), "rb"); if (!file) { @@ -130,34 +130,34 @@ static void closeFiles(vector& partitionFiles, FILE *& pitFile) if (pitFile) { - fclose(pitFile); + FileClose(pitFile); pitFile = nullptr; } // Close partition files for (vector::const_iterator it = partitionFiles.begin(); it != partitionFiles.end(); it++) - fclose(it->file); + FileClose(it->file); partitionFiles.clear(); } static bool sendTotalTransferSize(BridgeManager *bridgeManager, const vector& partitionFiles, FILE *pitFile, bool repartition) { - int totalBytes = 0; + unsigned int totalBytes = 0; for (vector::const_iterator it = partitionFiles.begin(); it != partitionFiles.end(); it++) { - fseek(it->file, 0, SEEK_END); - totalBytes += ftell(it->file); - rewind(it->file); + FileSeek(it->file, 0, SEEK_END); + totalBytes += (unsigned int)FileTell(it->file); + FileRewind(it->file); } if (repartition) { - fseek(pitFile, 0, SEEK_END); - totalBytes += ftell(pitFile); - rewind(pitFile); + FileSeek(pitFile, 0, SEEK_END); + totalBytes += (unsigned int)FileTell(pitFile); + FileRewind(pitFile); } bool success; @@ -168,7 +168,7 @@ static bool sendTotalTransferSize(BridgeManager *bridgeManager, const vector 0) { - rewind(pitFile); + FileRewind(pitFile); localPitData = new PitData(); localPitData->Unpack(pitFileBuffer); -- cgit v1.2.3