MCPcopy Create free account
hub / github.com/apache/nifi-minifi-cpp / read

Method read

libminifi/src/utils/file/FileSystem.cpp:41–58  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39}
40
41utils::optional<std::string> FileSystem::read(const std::string& file_name) {
42 std::ifstream input{file_name, std::ios::binary};
43 if (!input) {
44 return {};
45 }
46 input.exceptions(std::ios::failbit | std::ios::badbit);
47 std::string content{std::istreambuf_iterator<char>(input), {}};
48 if (encryptor_) {
49 try {
50 logger_->log_debug("Trying to decrypt file %s", file_name);
51 content = encryptor_->decrypt(content);
52 } catch(...) {
53 // tried to decrypt file but failed, use file as-is
54 logger_->log_debug("Decrypting file %s failed, using the file as-is", file_name);
55 }
56 }
57 return content;
58}
59
60bool FileSystem::write(const std::string& file_name, const std::string& file_content) {
61 std::ofstream output{file_name, std::ios::binary};

Callers 2

processMethod · 0.45
computeChecksumFunction · 0.45

Calls 2

log_debugMethod · 0.80
decryptMethod · 0.45

Tested by

no test coverage detected