syncqt: Do not needlessly rewrite header files on Windows
SyncScanner::writeIfDifferent compares the size in the buffer with the size of the existing file on disk to see whether the file should be rewritten. However, on Windows the sizes hardly ever matched, because the implicit \n to \r\n conversion only happened when writing the file in text mode using ofstream. Take this into account. Change-Id: Ic689390396fcc3a640640378743bd058f48a1779 Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
This commit is contained in:
parent
600752aa97
commit
603ff45228
@ -1534,8 +1534,14 @@ bool SyncScanner::writeIfDifferent(const std::string &outputFile, const std::str
|
||||
if (!std::filesystem::exists(outputDirectory))
|
||||
std::filesystem::create_directories(outputDirectory);
|
||||
|
||||
int expectedSize = buffer.size();
|
||||
#ifdef _WINDOWS
|
||||
// File on disk has \r\n instead of just \n
|
||||
expectedSize += std::count(buffer.begin(), buffer.end(), '\n');
|
||||
#endif
|
||||
|
||||
if (std::filesystem::exists(outputFilePath)
|
||||
&& buffer.size() == std::filesystem::file_size(outputFilePath)) {
|
||||
&& expectedSize == std::filesystem::file_size(outputFilePath)) {
|
||||
char rdBuffer[bufferSize];
|
||||
memset(rdBuffer, 0, bufferSize);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user