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

Method getBookmarkXmlFromFile

extensions/windows-event-log/Bookmark.cpp:166–203  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

164}
165
166bool Bookmark::getBookmarkXmlFromFile(std::wstring& bookmarkXml) {
167 bookmarkXml.clear();
168
169 std::wifstream file(filePath_);
170 if (!file.is_open()) {
171 return false;
172 }
173
174 // Generically is not efficient, but bookmarkXML is small ~100 bytes.
175 wchar_t c;
176 do {
177 file.read(&c, 1);
178 if (!file) {
179 break;
180 }
181
182 bookmarkXml += c;
183 } while (true);
184
185 file.close();
186
187 if (bookmarkXml.empty()) {
188 return true;
189 }
190
191 // '!' should be at the end of bookmark.
192 auto pos = bookmarkXml.find(L'!');
193 if (std::wstring::npos == pos) {
194 logger_->log_error("No '!' in bookmarXml '%ls'", bookmarkXml.c_str());
195 bookmarkXml.clear();
196 return false;
197 }
198
199 // Remove '!'.
200 bookmarkXml.resize(pos);
201
202 return true;
203}
204
205} /* namespace processors */
206} /* namespace minifi */

Callers

nothing calls this directly

Calls 7

log_errorMethod · 0.80
c_strMethod · 0.80
clearMethod · 0.45
readMethod · 0.45
closeMethod · 0.45
emptyMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected