| 164 | } |
| 165 | |
| 166 | bool 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 */ |