aboutsummaryrefslogtreecommitdiffstats
path: root/src/core/function/FileOperator.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/function/FileOperator.cpp')
-rw-r--r--src/core/function/FileOperator.cpp26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/core/function/FileOperator.cpp b/src/core/function/FileOperator.cpp
index fcbdb91c..41552246 100644
--- a/src/core/function/FileOperator.cpp
+++ b/src/core/function/FileOperator.cpp
@@ -32,7 +32,7 @@ bool GpgFrontend::FileOperator::ReadFile(const QString& file_name,
QByteArray& data) {
QFile file(file_name);
if (!file.open(QIODevice::ReadOnly)) {
- LOG(ERROR) << "failed to open file" << file_name.toStdString();
+ SPDLOG_ERROR("failed to open file: {}", file_name.toStdString());
return false;
}
data = file.readAll();
@@ -44,7 +44,7 @@ bool GpgFrontend::FileOperator::WriteFile(const QString& file_name,
const QByteArray& data) {
QFile file(file_name);
if (!file.open(QIODevice::WriteOnly)) {
- LOG(ERROR) << "failed to open file" << file_name.toStdString();
+ SPDLOG_ERROR("failed to open file: {}", file_name.toStdString());
return false;
}
file.write(data);
@@ -84,33 +84,33 @@ std::string GpgFrontend::FileOperator::CalculateHash(
<< file_path.filename().u8string().c_str() << std::endl;
QFile f(info.filePath());
- f.open(QFile::ReadOnly);
- auto buffer = f.readAll();
- ss << " " << _("file size(bytes)") << _(": ") << buffer.size()
- << std::endl;
- f.close();
if (f.open(QFile::ReadOnly)) {
- auto hash_md5 = QCryptographicHash(QCryptographicHash::Md5);
+ // read all data
+ auto buffer = f.readAll();
+ ss << " " << _("file size(bytes)") << _(": ") << buffer.size()
+ << std::endl;
+
// md5
+ auto hash_md5 = QCryptographicHash(QCryptographicHash::Md5);
hash_md5.addData(buffer);
auto md5 = hash_md5.result().toHex().toStdString();
- LOG(INFO) << "md5" << md5;
+ SPDLOG_DEBUG("md5 {}", md5);
ss << " "
<< "md5" << _(": ") << md5 << std::endl;
- auto hash_sha1 = QCryptographicHash(QCryptographicHash::Sha1);
// sha1
+ auto hash_sha1 = QCryptographicHash(QCryptographicHash::Sha1);
hash_sha1.addData(buffer);
auto sha1 = hash_sha1.result().toHex().toStdString();
- LOG(INFO) << "sha1" << sha1;
+ SPDLOG_DEBUG("sha1 {}", sha1);
ss << " "
<< "sha1" << _(": ") << sha1 << std::endl;
- auto hash_sha256 = QCryptographicHash(QCryptographicHash::Sha256);
// sha1
+ auto hash_sha256 = QCryptographicHash(QCryptographicHash::Sha256);
hash_sha256.addData(buffer);
auto sha256 = hash_sha256.result().toHex().toStdString();
- LOG(INFO) << "sha256" << sha256;
+ SPDLOG_DEBUG("sha256 {}", sha256);
ss << " "
<< "sha256" << _(": ") << sha256 << std::endl;