diff options
Diffstat (limited to 'occ_device.cpp')
-rw-r--r-- | occ_device.cpp | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/occ_device.cpp b/occ_device.cpp index b05dc09..6cd6a1f 100644 --- a/occ_device.cpp +++ b/occ_device.cpp @@ -12,10 +12,31 @@ namespace occ fs::path Device::bindPath = fs::path(OCC_HWMON_PATH) / "bind"; fs::path Device::unBindPath = fs::path(OCC_HWMON_PATH) / "unbind"; +std::string Device::getPathBack(const fs::path& path) +{ + if (path.empty()) + return std::string(); + + // Points to the last element in the path + auto conf = --path.end(); + + // The last element will be '.' if the path ends in '/' + // This behavior differs between filesystem and experimental::filesystem + // Verify there is an element before too + if (!conf->compare(".") && conf != path.begin()) + { + return *(--conf); + } + else + { + return *conf; + } +} + bool Device::master() const { int master; - auto masterFile = fs::path(DEV_PATH) / config / "occ_master"; + auto masterFile = devPath / "occ_master"; std::ifstream file(masterFile, std::ios::in); if (!file) |