From 13b88573005d84cc0ebcd7e7bf4dd488673919d3 Mon Sep 17 00:00:00 2001 From: dm1try Date: Sun, 3 May 2020 23:46:55 +0300 Subject: path: add helper for checking a file extension --- src/nvim/path.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/nvim/path.c') diff --git a/src/nvim/path.c b/src/nvim/path.c index f52fbbd5c8..2de7e00ddb 100644 --- a/src/nvim/path.c +++ b/src/nvim/path.c @@ -1704,6 +1704,13 @@ int path_with_url(const char *fname) return path_is_url(p); } +bool path_with_extension(const char *path, const char *extension) +{ + const char *last_dot = strrchr(path, '.'); + if (!last_dot) { return false; } + return strcmp(last_dot + 1, extension) == 0; +} + /* * Return TRUE if "name" is a full (absolute) path name or URL. */ -- cgit