Skip to content

Commit

Permalink
Merge ba207a0 into 786b0cc
Browse files Browse the repository at this point in the history
  • Loading branch information
agarny committed Feb 22, 2019
2 parents 786b0cc + ba207a0 commit 21bc5d2
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
18 changes: 18 additions & 0 deletions src/plugins/miscellaneous/Core/src/corecliutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,24 @@ QString sha1(const QString &pString)

//==============================================================================

QString fileSha1(const QString &pFileName)
{
// Return the SHA-1 value of the given file

QFile file(pFileName);

if (file.open(QFile::ReadOnly)) {
QCryptographicHash hash(QCryptographicHash::Sha1);

if (hash.addData(&file))
return hash.result();
}

return QString();
}

//==============================================================================

void stringPositionAsLineColumn(const QString &pString, const QString &pEol,
int pPosition, int &pLine, int &pColumn)
{
Expand Down
1 change: 1 addition & 0 deletions src/plugins/miscellaneous/Core/src/corecliutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ QString CORE_EXPORT formatTime(qint64 pTime);

QString CORE_EXPORT sha1(const QByteArray &pByteArray);
QString CORE_EXPORT sha1(const QString &pString);
QString CORE_EXPORT fileSha1(const QString &pFileName);

void CORE_EXPORT stringPositionAsLineColumn(const QString &pString,
const QString &pEol, int pPosition,
Expand Down
10 changes: 2 additions & 8 deletions src/plugins/miscellaneous/Core/src/file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,9 @@ File::Status File::check()

QString File::sha1(const QString &pFileName)
{
// Compute the SHA-1 value for the given file, if it still exists and can be
// opened
// Return the SHA-1 value of the given file

QByteArray fileContents;

if (readFile(pFileName, fileContents))
return Core::sha1(fileContents);
else
return QString();
return Core::fileSha1(pFileName);
}

//==============================================================================
Expand Down

0 comments on commit 21bc5d2

Please sign in to comment.