diff options
-rw-r--r-- | src/common.c | 18 | ||||
-rw-r--r-- | src/common.h | 2 | ||||
-rw-r--r-- | src/main.c | 5 |
3 files changed, 24 insertions, 1 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; +} + diff --git a/src/common.h b/src/common.h index c462a80..5a3deea 100644 --- a/src/common.h +++ b/src/common.h @@ -38,4 +38,6 @@ int str_contains_case_sensitive(char*, char*); int str_contains_case_insensitive(char*, char*); +int strip_extension(char*); + #endif @@ -54,7 +54,10 @@ void get_help() { void list_notes(note_list_t* list) { // List notes for(int i = 0; i < list->count; i++) { - printf("* %s\n", list->names[i]); + char name[128]; + strcpy(name, list->names[i]); + strip_extension(name); + printf("* %s\n", name); } } |