sysfs.cpp (641299377c7352f9c946edf1527e5ded73c01f52) sysfs.cpp (02e598ab445833e0ce615f88ac0aed7288a100e0)
1/**
2 * Copyright © 2016 IBM Corporation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0

--- 206 unchanged lines hidden (view full) ---

215 size_t pos = 0;
216 std::string path = p;
217 while ((pos = path.find("--")) != std::string::npos)
218 {
219 path.replace(pos, 2, ":");
220 }
221
222 auto dir_iter = fs::directory_iterator(path);
1/**
2 * Copyright © 2016 IBM Corporation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0

--- 206 unchanged lines hidden (view full) ---

215 size_t pos = 0;
216 std::string path = p;
217 while ((pos = path.find("--")) != std::string::npos)
218 {
219 path.replace(pos, 2, ":");
220 }
221
222 auto dir_iter = fs::directory_iterator(path);
223 auto hwmonInst = std::find_if(dir_iter, end(dir_iter),
224 [](const fs::directory_entry& d) {
225 return (d.path().filename().string().find("hwmon") !=
226 std::string::npos);
227 });
223 auto hwmonInst = std::find_if(
224 dir_iter, end(dir_iter), [](const fs::directory_entry& d) {
225 return (d.path().filename().string().find("hwmon") !=
226 std::string::npos);
227 });
228 if (hwmonInst != end(dir_iter))
229 {
230 return hwmonInst->path();
231 }
232 }
233 catch (const std::exception& e)
234 {
235 stdplus::print(stderr,
236 "Unable to find hwmon directory from the dev path: {}\n",
237 devPath.c_str());
238 }
239 return emptyString;
240}
241
242} // namespace sysfs
243
244// vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4
228 if (hwmonInst != end(dir_iter))
229 {
230 return hwmonInst->path();
231 }
232 }
233 catch (const std::exception& e)
234 {
235 stdplus::print(stderr,
236 "Unable to find hwmon directory from the dev path: {}\n",
237 devPath.c_str());
238 }
239 return emptyString;
240}
241
242} // namespace sysfs
243
244// vim: tabstop=8 expandtab shiftwidth=4 softtabstop=4