aboutsummaryrefslogtreecommitdiffstats
path: root/src/core/function/DataObjectOperator.cpp
diff options
context:
space:
mode:
authorsaturneric <[email protected]>2023-11-06 12:49:44 +0000
committersaturneric <[email protected]>2023-11-06 12:49:44 +0000
commit889cb8092381b073a0f4a0411a4ede04cd7bdd14 (patch)
tree87ae80ee7be8b426afe869baff7c99384bbafaaa /src/core/function/DataObjectOperator.cpp
parentrefactor: clean up core's codes (diff)
downloadGpgFrontend-889cb8092381b073a0f4a0411a4ede04cd7bdd14.tar.gz
GpgFrontend-889cb8092381b073a0f4a0411a4ede04cd7bdd14.zip
refactor: improve the code structure of core
Diffstat (limited to 'src/core/function/DataObjectOperator.cpp')
-rw-r--r--src/core/function/DataObjectOperator.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/core/function/DataObjectOperator.cpp b/src/core/function/DataObjectOperator.cpp
index fcf77319..2fb794c5 100644
--- a/src/core/function/DataObjectOperator.cpp
+++ b/src/core/function/DataObjectOperator.cpp
@@ -32,13 +32,13 @@
#include <boost/date_time.hpp>
-#include "core/function/FileOperator.h"
#include "core/function/PassphraseGenerator.h"
+#include "core/utils/IOUtils.h"
void GpgFrontend::DataObjectOperator::init_app_secure_key() {
SPDLOG_DEBUG("initializing application secure key");
- FileOperator::WriteFileStd(app_secure_key_path_,
- PassphraseGenerator::GetInstance().Generate(256));
+ WriteFileStd(app_secure_key_path_,
+ PassphraseGenerator::GetInstance().Generate(256));
std::filesystem::permissions(
app_secure_key_path_,
std::filesystem::perms::owner_read | std::filesystem::perms::owner_write);
@@ -53,7 +53,7 @@ GpgFrontend::DataObjectOperator::DataObjectOperator(int channel)
}
std::string key;
- if (!FileOperator::ReadFileStd(app_secure_key_path_.u8string(), key)) {
+ if (!ReadFileStd(app_secure_key_path_.u8string(), key)) {
SPDLOG_ERROR("failed to read app secure key file: {}",
app_secure_key_path_.u8string());
throw std::runtime_error("failed to read app secure key file");
@@ -96,7 +96,7 @@ std::string GpgFrontend::DataObjectOperator::SaveDataObj(
SPDLOG_DEBUG("saving data object {} to {} , size: {} bytes", _hash_obj_key,
obj_path.u8string(), encoded.size());
- FileOperator::WriteFileStd(obj_path.u8string(), encoded.toStdString());
+ WriteFileStd(obj_path.u8string(), encoded.toStdString());
return _key.empty() ? _hash_obj_key : std::string();
}
@@ -119,7 +119,7 @@ std::optional<nlohmann::json> GpgFrontend::DataObjectOperator::GetDataObject(
}
std::string buffer;
- if (!FileOperator::ReadFileStd(obj_path.u8string(), buffer)) {
+ if (!ReadFileStd(obj_path.u8string(), buffer)) {
SPDLOG_ERROR("failed to read data object: {}", _key);
return {};
}
@@ -156,7 +156,7 @@ GpgFrontend::DataObjectOperator::GetDataObjectByRef(const std::string& _ref) {
if (!std::filesystem::exists(obj_path)) return {};
std::string buffer;
- if (!FileOperator::ReadFileStd(obj_path.u8string(), buffer)) return {};
+ if (!ReadFileStd(obj_path.u8string(), buffer)) return {};
auto encoded = QByteArray::fromStdString(buffer);
QAESEncryption encryption(QAESEncryption::AES_256, QAESEncryption::ECB,