diff options
| author | Carl Hetherington <cth@carlh.net> | 2025-03-03 22:40:13 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2025-03-08 00:12:07 +0100 |
| commit | 0f2ed1b51af625767b9e0c41eb59651f2ceb1d88 (patch) | |
| tree | 70d0a6d42312adc7b9c43018f78420beabc888e7 /src/lib/grok/util.cc | |
| parent | 641f5f2f61b77d79cb1e8c737cda0766b1ee2de8 (diff) | |
Move get_gpu_names() to its own file.
Diffstat (limited to 'src/lib/grok/util.cc')
| -rw-r--r-- | src/lib/grok/util.cc | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/src/lib/grok/util.cc b/src/lib/grok/util.cc new file mode 100644 index 000000000..e9b535df8 --- /dev/null +++ b/src/lib/grok/util.cc @@ -0,0 +1,50 @@ +/* + Copyright (C) 2023 Grok Image Compression Inc. + + This file is part of DCP-o-matic. + + DCP-o-matic is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DCP-o-matic is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>. + +*/ + + +#include "util.h" + + +using std::string; +using std::vector; + + +vector<string> +get_gpu_names(boost::filesystem::path binary, boost::filesystem::path filename) +{ + // Execute the GPU listing program and redirect its output to a file + if (std::system((binary.string() + " > " + filename.string()).c_str()) < 0) { + return {}; + } + + std::vector<std::string> gpu_names; + std::ifstream file(filename.c_str()); + if (file.is_open()) + { + std::string line; + while (std::getline(file, line)) + gpu_names.push_back(line); + file.close(); + } + + return gpu_names; +} + + |
