diff --git a/AK/FileSystemPath.cpp b/AK/FileSystemPath.cpp index 971bbf52bd..e094c1de3d 100644 --- a/AK/FileSystemPath.cpp +++ b/AK/FileSystemPath.cpp @@ -45,5 +45,11 @@ bool FileSystemPath::canonicalize(bool resolve_symbolic_links) return true; } +bool FileSystemPath::has_extension(StringView extension) const +{ + // FIXME: This is inefficient, expand StringView with enough functionality that we don't need to copy strings here. + String extension_string = extension; + return m_string.to_lowercase().ends_with(extension_string.to_lowercase()); } +} diff --git a/AK/FileSystemPath.h b/AK/FileSystemPath.h index 64827157a7..3e56523269 100644 --- a/AK/FileSystemPath.h +++ b/AK/FileSystemPath.h @@ -16,6 +16,8 @@ public: const Vector& parts() const { return m_parts; } + bool has_extension(StringView) const; + private: bool canonicalize(bool resolve_symbolic_links = false);