aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/main.c b/src/main.c
index 42b4173..667a79f 100644
--- a/src/main.c
+++ b/src/main.c
@@ -447,10 +447,26 @@ ftag_add_one_file(sqlite3 *db, int *next_id, const char *file, uint32_t file_sum
date = time_from_str(date_str);
}
+ char extension[16];
+ /* Find the position of the last dot character in file name. If found,
+ * everything that follows is considered as the extension. */
+ int i = strlen(file) - 1;
+ while ((i >= 1) && (file[i] != '.'))
+ i--;
+ if ((i >= 1) && (i < strlen(file))) {
+ assert(strlen(file + i + 1) < 16);
+ strcpy(extension, file + i + 1);
+ }
+ else {
+ extension[0] = '\0';
+ }
+
memset(sql, 0, sizeof(sql));
snprintf(sql, sizeof(sql)-1,
- "INSERT INTO files VALUES(%d, '%s', '%s', '%s', %ld, %u)",
- *next_id, canonical_name, full_name, description, date, file_sum);
+ "INSERT INTO files VALUES(%d, '%s', '%s', '%s', "
+ "%ld, %u, '%s')",
+ *next_id, canonical_name, full_name, description,
+ date, file_sum, extension);
rc = sqlite3_exec(db, sql, NULL, NULL, NULL);
sqlite3_check(rc, db);
(*next_id)++;