source:
src/utils/strutils.c
@
5fc6e81
Last change on this file since 5fc6e81 was 20ce2ad, checked in by , 6 years ago | |
---|---|
|
|
File size: 1.3 KB |
Rev | Line | |
---|---|---|
[20ce2ad] | 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 | if (!filename) return NULL; | |
26 | // find last occurence of dot character | |
27 | const char_t *ext = strrchr(filename, '.'); | |
28 | if (!ext || ext == filename) return ""; | |
29 | else return ext + 1; | |
30 | } | |
31 | ||
32 | uint_t aubio_str_extension_matches(const char_t *ext, const char_t *pattern) | |
33 | { | |
34 | return ext && pattern && (strncasecmp(ext, pattern, PATH_MAX) == 0); | |
35 | } | |
36 | ||
37 | uint_t aubio_str_path_has_extension(const char_t *filename, | |
38 | const char_t *pattern) | |
39 | { | |
40 | const char_t *ext = aubio_str_get_extension(filename); | |
41 | return aubio_str_extension_matches(ext, pattern); | |
42 | } |
Note: See TracBrowser
for help on using the repository browser.