| #include "dbus_utility.hpp" |
| |
| #include "logging.hpp" |
| |
| #include <boost/system/error_code.hpp> // IWYU pragma: keep |
| #include <sdbusplus/asio/property.hpp> |
| #include <sdbusplus/message/native_types.hpp> |
| |
| #include <array> |
| #include <cstddef> |
| #include <cstdint> |
| #include <filesystem> |
| #include <functional> |
| #include <regex> |
| #include <span> |
| #include <sstream> |
| #include <string> |
| #include <string_view> |
| #include <tuple> |
| #include <utility> |
| #include <variant> |
| #include <vector> |
| |
| namespace dbus |
| { |
| |
| namespace utility |
| { |
| |
| bool getNthStringFromPath(const std::string& path, int index, |
| std::string& result) |
| { |
| if (index < 0) |
| { |
| return false; |
| } |
| |
| std::filesystem::path p1(path); |
| int count = -1; |
| for (auto const& element : p1) |
| { |
| if (element.has_filename()) |
| { |
| ++count; |
| if (count == index) |
| { |
| result = element.stem().string(); |
| break; |
| } |
| } |
| } |
| return count >= index; |
| } |
| |
| } // namespace utility |
| } // namespace dbus |