diff options
| author | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2017-03-27 13:41:02 -0400 |
|---|---|---|
| committer | Brad Bishop <bradleyb@fuzziesquirrel.com> | 2017-03-27 13:57:44 -0400 |
| commit | 5ec68abbcbac6e3475cff13cf151e6569fc07337 (patch) | |
| tree | c7eb3b1041383888174bba50589b574486d71c51 /sysfs.cpp | |
| parent | 973886db122187b4d30ad0d359c1e9db0e23a706 (diff) | |
| download | phosphor-hwmon-5ec68abbcbac6e3475cff13cf151e6569fc07337.tar.gz phosphor-hwmon-5ec68abbcbac6e3475cff13cf151e6569fc07337.zip | |
Use std::filesystem when generating callout paths
Change-Id: Ia4dbe7e27368a7136d3767f105f6af78d9627c3f
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
Diffstat (limited to 'sysfs.cpp')
| -rw-r--r-- | sysfs.cpp | 16 |
1 files changed, 9 insertions, 7 deletions
@@ -51,11 +51,14 @@ int readSysfsWithCallout(const std::string& root, const std::string& id, const std::string& sensor) { + namespace fs = std::experimental::filesystem; + int value = 0; - std::string instancePath = root + '/' + instance; + std::ifstream ifs; + fs::path instancePath{root}; + instancePath /= instance; std::string fullPath = make_sysfs_path(instancePath, type, id, sensor); - std::ifstream ifs; ifs.exceptions(std::ifstream::failbit | std::ifstream::badbit @@ -69,17 +72,16 @@ int readSysfsWithCallout(const std::string& root, { // Too many GCC bugs (53984, 66145) to do // this the right way... - using Cleanup = phosphor::utility::Free<char>; // errno should still reflect the error from the failing open // or read system calls that got us here. auto rc = errno; - std::string devicePath = instancePath + "/device"; - auto real = std::unique_ptr<char, Cleanup>( - realpath(devicePath.c_str(), nullptr)); + instancePath /= "device"; phosphor::logging::log<phosphor::logging::level::ERR>( strerror(rc), - phosphor::logging::entry("CALLOUT_DEVICE_PATH=%s", real.get()), + phosphor::logging::entry( + "CALLOUT_DEVICE_PATH=%s", + fs::canonical(instancePath).c_str()), phosphor::logging::entry("CALLOUT_ERRNO=%d", rc)); exit(EXIT_FAILURE); } |

