diff --git a/common/lib/kernel/devices/ip_device.cpp b/common/lib/kernel/devices/ip_device.cpp index 5aafb0de9..7a6a4a3ee 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 28b6c4796..4c3e5258f 100644 --- a/common/lib/kernel/devices/platform_device.cpp +++ b/common/lib/kernel/devices/platform_device.cpp @@ -48,7 +48,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); -} \ No newline at end of file +std::string PlatformDevice::name() const { return this->m_path.filename(); } \ No newline at end of file