Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
blaar
blibs
blc_core
Commits
78b7ed8c
Commit
78b7ed8c
authored
Nov 16, 2016
by
Arnaud Blanchard
Browse files
Add function to get extension of a filename
parent
4eebd7c2
Changes
2
Hide whitespace changes
Inline
Side-by-side
include/blc_tools.h
View file @
78b7ed8c
...
...
@@ -252,7 +252,9 @@ char rand_char();
///Close both part (input/output) of a pipe
void
blc_close_pipe
(
int
*
pipe
);
//int set_iovec(struct iovec *iovec, void *data, size_t size, ...);
///Get the extension (text after last '.') in the filename
char
const
*
blc_get_filename_extension
(
char
const
*
filename
);
END_EXTERN_C
///@}
#endif
/* BLC_TOOLS_H */
...
...
src/blc_tools.cpp
View file @
78b7ed8c
...
...
@@ -256,6 +256,20 @@ void blc_close_pipe(int *pipe)
*/
char
const
*
blc_get_filename_extension
(
char
const
*
filename
){
char
const
*
ext
=
NULL
,
*
next_ext
;
next_ext
=
strchr
(
filename
,
'.'
);
if
(
next_ext
==
NULL
)
return
NULL
;
do
{
ext
=
next_ext
;
next_ext
=
strchr
(
ext
+
1
,
'.'
);
}
while
(
next_ext
);
return
ext
+
1
;
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment