| 1 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 2 | // Copyright 2019 Juan Palacios <[email protected]> |
| 3 | |
| 4 | #include "hwiddatasource.h" |
| 5 | |
| 6 | #include "common/fileutils.h" |
| 7 | #include <utility> |
| 8 | |
| 9 | HWIDDataSource::HWIDDataSource(std::string const &path) noexcept |
| 10 | : path_(path) |
| 11 | { |
| 12 | } |
| 13 | |
| 14 | std::string HWIDDataSource::source() const |
| 15 | { |
| 16 | return path_; |
| 17 | } |
| 18 | |
| 19 | bool HWIDDataSource::read(std::vector<char> &data) |
| 20 | { |
| 21 | auto fileData = Utils::File::readFile(path_); |
| 22 | if (!fileData.empty()) { |
| 23 | std::swap(data, fileData); |
| 24 | return true; |
| 25 | } |
| 26 | return false; |
| 27 | } |