diff --git a/common/lib/kernel/devices/ip_device.cpp b/common/lib/kernel/devices/ip_device.cpp index e7a3849b1..12dfc84ca 100644 --- a/common/lib/kernel/devices/ip_device.cpp +++ b/common/lib/kernel/devices/ip_device.cpp @@ -41,9 +41,7 @@ size_t IpDevice::addr() const { } bool IpDevice::is_path_valid(const std::filesystem::path unsafe_path) { - // Split the string at last slash - int pos = unsafe_path.u8string().rfind('/'); - std::string assumed_device_name = unsafe_path.u8string().substr(pos + 1); + std::string assumed_device_name = unsafe_path.filename(); // Match format of hexaddr.devicename if (!std::regex_match(assumed_device_name, diff --git a/common/lib/kernel/devices/platform_device.cpp b/common/lib/kernel/devices/platform_device.cpp index b66a19577..276c31eae 100644 --- a/common/lib/kernel/devices/platform_device.cpp +++ b/common/lib/kernel/devices/platform_device.cpp @@ -46,7 +46,4 @@ std::filesystem::path PlatformDevice::override_path() const { return this->m_override_path; } -std::string PlatformDevice::name() const { - size_t pos = this->m_path.u8string().rfind('/'); - return this->m_path.u8string().substr(pos + 1); -} +std::string PlatformDevice::name() const { return this->m_path.filename(); }