| 29 | namespace file { |
| 30 | |
| 31 | FileSystem::FileSystem(bool should_encrypt_on_write, utils::optional<utils::crypto::EncryptionProvider> encryptor) |
| 32 | : should_encrypt_on_write_(should_encrypt_on_write), |
| 33 | encryptor_(std::move(encryptor)) { |
| 34 | if (should_encrypt_on_write_ && !encryptor) { |
| 35 | std::string err_message = "Requested file encryption but no encryption utility was provided"; |
| 36 | logger_->log_error(err_message.c_str()); |
| 37 | throw std::invalid_argument(err_message); |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | utils::optional<std::string> FileSystem::read(const std::string& file_name) { |
| 42 | std::ifstream input{file_name, std::ios::binary}; |