|
|
|
@ -162,15 +162,23 @@ qint64 Utils::Fs::computePathSize(const Path &path)
@@ -162,15 +162,23 @@ qint64 Utils::Fs::computePathSize(const Path &path)
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Makes deep comparison of two files to make sure they are identical. |
|
|
|
|
* The point is about the file contents. If the files do not exist then |
|
|
|
|
* the paths refers to nothing and therefore we cannot say the files are same |
|
|
|
|
* (because there are no files!) |
|
|
|
|
*/ |
|
|
|
|
bool Utils::Fs::sameFiles(const Path &path1, const Path &path2) |
|
|
|
|
{ |
|
|
|
|
QFile f1 {path1.data()}; |
|
|
|
|
QFile f2 {path2.data()}; |
|
|
|
|
if (!f1.exists() || !f2.exists()) return false; |
|
|
|
|
if (f1.size() != f2.size()) return false; |
|
|
|
|
if (!f1.open(QIODevice::ReadOnly)) return false; |
|
|
|
|
if (!f2.open(QIODevice::ReadOnly)) return false; |
|
|
|
|
|
|
|
|
|
if (!f1.exists() || !f2.exists()) |
|
|
|
|
return false; |
|
|
|
|
if (path1 == path2) |
|
|
|
|
return true; |
|
|
|
|
if (f1.size() != f2.size()) |
|
|
|
|
return false; |
|
|
|
|
if (!f1.open(QIODevice::ReadOnly) || !f2.open(QIODevice::ReadOnly)) |
|
|
|
|
return false; |
|
|
|
|
|
|
|
|
|
const int readSize = 1024 * 1024; // 1 MiB
|
|
|
|
|
while (!f1.atEnd() && !f2.atEnd()) |
|
|
|
|