From 85b1e5e473154c10bcf042bcce24253b260f9436 Mon Sep 17 00:00:00 2001 From: Jaime Thomas Date: Wed, 21 May 2008 03:08:27 +0000 Subject: [PATCH] Fix problem when adding an external file to a recursively added directory --- experimental/ecdb/trunk/src/ecdb.c | 5 +++- experimental/ecdb/trunk/src/ecdb_image.c | 31 ++++++++++++++++-------- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/experimental/ecdb/trunk/src/ecdb.c b/experimental/ecdb/trunk/src/ecdb.c index 8ba3b391..9428b2eb 100644 --- a/experimental/ecdb/trunk/src/ecdb.c +++ b/experimental/ecdb/trunk/src/ecdb.c @@ -13,7 +13,6 @@ main(int argc, char **argv) { int i; int ret = 0; - Ecdb_Source *src; if (!ecore_init()) { @@ -40,11 +39,13 @@ main(int argc, char **argv) /* Start testing */ Ecdb_Burn_Project *proj; + Ecdb_Source *src; proj = ecdb_burn_project_new(); i = 1; while ((i < argc) && (argv)) { + /* No trailing slashes */ if (ecore_file_exists(argv[i])) { if (ecore_file_is_dir(argv[i])) @@ -52,10 +53,12 @@ main(int argc, char **argv) src = ecdb_source_new(); ecdb_source_data_set(src, argv[i], ret); ecdb_source_child_append(proj->files, src); + ret = 0; } i++; } + proj->publisher_id = proj->data_preparer_id = proj->system_id = proj->application_id = proj->copywrite_id = proj->abstract_id = proj->biblio_id = "ecdb"; diff --git a/experimental/ecdb/trunk/src/ecdb_image.c b/experimental/ecdb/trunk/src/ecdb_image.c index 24775bc3..d178338e 100644 --- a/experimental/ecdb/trunk/src/ecdb_image.c +++ b/experimental/ecdb/trunk/src/ecdb_image.c @@ -44,6 +44,12 @@ ecdb_source_data_set(Ecdb_Source *src, const char *dst, unsigned char rec) void ecdb_source_child_append(Ecdb_Source *src, Ecdb_Source *child) { + if (src == child) + { + printf("Trying to make a parent of itself!\n"); + return; + } + src->num_children++; src->children = realloc(src->children, sizeof(Ecdb_Source) * (src->num_children + 1)); @@ -54,8 +60,7 @@ ecdb_source_child_append(Ecdb_Source *src, Ecdb_Source *child) void ecdb_source_add_children_rec(Ecdb_Source *parent, IsoImage *image) { - IsoDir *cd; - IsoNode *cn; + IsoDir *cd = NULL; Ecdb_Source *cs; int i; @@ -65,27 +70,33 @@ ecdb_source_add_children_rec(Ecdb_Source *parent, IsoImage *image) i = 0; while ((cs = parent->children[i])) { + /* If recursive, let library add for us */ if (cs->rec) - iso_tree_add_dir_rec(image, ISO_DIR(parent->node), - cs->dst); + { + iso_tree_add_new_dir(ISO_DIR(parent->node), + ecore_file_file_get(cs->dst), &cd); + iso_tree_add_dir_rec(image, cd, cs->dst); + } + + /* If the source has children, find the node from above + * (if applicable), and recursively add to it */ if (cs->num_children) { - /* If not created above, make one here */ - if (!iso_tree_path_to_node(image, cs->dst, &cn)) + if (!cd) { iso_tree_add_new_dir(ISO_DIR(parent->node), - cs->dst, &cd); - cs->node = ISO_NODE(cd); + ecore_file_file_get(cs->dst), &cd); } - else - cs->node = cn; + cs->node = ISO_NODE(cd); ecdb_source_add_children_rec(cs, image); } /* file */ if ((!cs->rec) && (!cs->num_children)) + { iso_tree_add_node(image, ISO_DIR(parent->node), cs->dst, NULL); + } i++; } }