source:
src/utils/strutils.c
@
135bc14
Last change on this file since 135bc14 was 8fe522d, checked in by , 6 years ago | |
---|---|
|
|
File size: 1.3 KB |
Line | |
---|---|
1 | /* |
2 | Copyright (C) 2018 Paul Brossier <piem@aubio.org> |
3 | |
4 | This file is part of aubio. |
5 | |
6 | aubio is free software: you can redistribute it and/or modify |
7 | it under the terms of the GNU General Public License as published by |
8 | the Free Software Foundation, either version 3 of the License, or |
9 | (at your option) any later version. |
10 | |
11 | aubio is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 | GNU General Public License for more details. |
15 | |
16 | You should have received a copy of the GNU General Public License |
17 | along with aubio. If not, see <http://www.gnu.org/licenses/>. |
18 | |
19 | */ |
20 | |
21 | #include "aubio_priv.h" |
22 | |
23 | const char_t *aubio_str_get_extension(const char_t *filename) |
24 | { |
25 | // find last occurence of dot character |
26 | const char_t *ext; |
27 | if (!filename) return NULL; |
28 | ext = strrchr(filename, '.'); |
29 | if (!ext || ext == filename) return ""; |
30 | else return ext + 1; |
31 | } |
32 | |
33 | uint_t aubio_str_extension_matches(const char_t *ext, const char_t *pattern) |
34 | { |
35 | return ext && pattern && (strncasecmp(ext, pattern, PATH_MAX) == 0); |
36 | } |
37 | |
38 | uint_t aubio_str_path_has_extension(const char_t *filename, |
39 | const char_t *pattern) |
40 | { |
41 | const char_t *ext = aubio_str_get_extension(filename); |
42 | return aubio_str_extension_matches(ext, pattern); |
43 | } |
Note: See TracBrowser
for help on using the repository browser.