arpadboda commented on a change in pull request #580: MINIFICPP-30: Add support
for regex with Multiple file mode
URL: https://github.com/apache/nifi-minifi-cpp/pull/580#discussion_r296626123
##########
File path: extensions/standard-processors/processors/TailFile.cpp
##########
@@ -131,51 +203,80 @@ void TailFile::parseStateFileLine(char *buf) {
key = trimRight(key);
value = trimRight(value);
- if (key == "FILENAME")
- this->_currentTailFileName = value;
- if (key == "POSITION")
- this->_currentTailFilePosition = std::stoi(value);
+ if (key == "FILENAME") {
+ std::size_t found =
value.find_last_of(utils::file::FileUtils::get_separator());
+ auto fileLocation = value.substr(0, found);
+ auto fileName = value.substr(found + 1);
+ tail_states_.insert(std::make_pair(value, TailState { fileLocation,
fileName, 0, 0 }));
+ }
+ if (key == "POSITION") {
+ // for backwards compatibility
+ if (tail_states_.size() != 1) {
+ throw minifi::Exception(ExceptionType::PROCESSOR_EXCEPTION,
"Incompatible state file types");
+ }
+ tail_states_.begin()->second.currentTailFilePosition_ = std::stoi(value);
+ }
+ if (key.find(CURRENT_STR) == 0) {
+ const auto file = key.substr(strlen(CURRENT_STR) + 1);
+
+ std::size_t found =
value.find_last_of(utils::file::FileUtils::get_separator());
Review comment:
I think we are going to need this in many classes, so in the long term it
would be nice to extend FileUtils with something like "getFileName" and
"getFolderPath".
Doesn't belong to the scope of this PR, just a note for future myself.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services