From b9771921fc27f1b08f79e74d3a01331e4cbf3228 Mon Sep 17 00:00:00 2001 From: Al Date: Mon, 20 Jul 2015 16:31:43 -0400 Subject: [PATCH] [fix] Path joins in geodb_builder use new char_array methods --- src/geodb_builder.c | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/src/geodb_builder.c b/src/geodb_builder.c index f6b098e9..92e00777 100644 --- a/src/geodb_builder.c +++ b/src/geodb_builder.c @@ -384,34 +384,19 @@ bool geodb_builder_add_to_trie(geodb_builder_t *self, char *key, uint16_t addres } -void join_path(char_array *path, char *dir, char *filename) { - char_array_clear(path); - bool strip_separator = strncmp(dir + strlen(dir) - 1, PATH_SEPARATOR, PATH_SEPARATOR_LEN) == 0; - - char_array_cat(path, dir); - if (!strip_separator) { - char_array_cat(path, PATH_SEPARATOR); - } - char_array_cat(path, filename); - -} - - bool geodb_finalize(geodb_builder_t *self, char *output_dir) { - bool strip_output_separator = strncmp(output_dir + strlen(output_dir) - 1, PATH_SEPARATOR, PATH_SEPARATOR_LEN) == 0; char_array *path = char_array_new_size(strlen(output_dir)); - join_path(path, output_dir, GEODB_TRIE_FILENAME); + char_array_add_joined(path, PATH_SEPARATOR, true, 2, output, GEODB_TRIE_FILENAME); char *trie_path = char_array_get_string(path); trie_save(self->trie, trie_path); - char *trie_filename = char_array_get_string(path); + char_array_add_joined(path, PATH_SEPARATOR, true, 2, output_dir, GEODB_HASH_FILENAME); - join_path(path, output_dir, GEODB_HASH_FILENAME); char *hash_filename = strdup(char_array_get_string(path)); - join_path(path, output_dir, GEODB_LOG_FILENAME); + char_array_add_joined(path, PATH_SEPARATOR, true, 2, output, GEODB_LOG_FILENAME); char *log_filename = char_array_get_string(path); if (self->log_writer != NULL) {