| 27 | : m_cssFile(std::move(cssFile)), m_callback(std::move(callback)) {} |
| 28 | |
| 29 | std::string waybar::CssReloadHelper::getFileContents(const std::string& filename) { |
| 30 | if (filename.empty()) { |
| 31 | return {}; |
| 32 | } |
| 33 | |
| 34 | std::ifstream file(filename); |
| 35 | if (!file.is_open()) { |
| 36 | return {}; |
| 37 | } |
| 38 | |
| 39 | return {(std::istreambuf_iterator<char>(file)), std::istreambuf_iterator<char>()}; |
| 40 | } |
| 41 | |
| 42 | std::string waybar::CssReloadHelper::findPath(const std::string& filename) { |
| 43 | // try path and fallback to looking relative to the config |