diff options
Diffstat (limited to 'src/common.c')
-rw-r--r-- | src/common.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/common.c b/src/common.c index e2ca4f4..65eb1ad 100644 --- a/src/common.c +++ b/src/common.c @@ -292,3 +292,21 @@ int str_contains_case_sensitive(char* str, char* term) { } return 0; } + +/** + * Removes the extension from the given string filename + * + * @param filename Filename/path to strip extension from + * + * @return int Result of the strip operation + */ +int strip_extension(char* filename) { + for(int i = strlen(filename); i > 0; i--) { + if(filename[i] == '.') { + filename[i] = '\0'; + return 0; + } + } + return -1; +} + |