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

Function openFile

extensions/standard-processors/processors/TailFile.cpp:175–189  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

173};
174
175void openFile(const std::string &file_name, uint64_t offset, std::ifstream &input_stream, const std::shared_ptr<logging::Logger> &logger) {
176 logger->log_debug("Opening %s", file_name);
177 input_stream.open(file_name.c_str(), std::fstream::in | std::fstream::binary);
178 if (!input_stream.is_open() || !input_stream.good()) {
179 input_stream.close();
180 throw Exception(FILE_OPERATION_EXCEPTION, "Could not open file: " + file_name);
181 }
182 if (offset != 0U) {
183 input_stream.seekg(offset, std::ifstream::beg);
184 if (!input_stream.good()) {
185 logger->log_error("Seeking to %" PRIu64 " failed for file %s (does file/filesystem support seeking?)", offset, file_name);
186 throw Exception(FILE_OPERATION_EXCEPTION, "Could not seek file " + file_name + " to offset " + std::to_string(offset));
187 }
188 }
189}
190
191constexpr std::size_t BUFFER_SIZE = 4096;
192

Callers 2

FileReaderCallbackMethod · 0.85

Calls 7

ExceptionClass · 0.85
log_debugMethod · 0.80
openMethod · 0.80
c_strMethod · 0.80
log_errorMethod · 0.80
to_stringFunction · 0.50
closeMethod · 0.45

Tested by

no test coverage detected