Fix problem when adding an external file to a recursively added directory

This commit is contained in:
Jaime Thomas 2008-05-21 03:08:27 +00:00
parent 7625898596
commit 85b1e5e473
2 changed files with 25 additions and 11 deletions

View File

@ -13,7 +13,6 @@ main(int argc, char **argv)
{ {
int i; int i;
int ret = 0; int ret = 0;
Ecdb_Source *src;
if (!ecore_init()) if (!ecore_init())
{ {
@ -40,11 +39,13 @@ main(int argc, char **argv)
/* Start testing */ /* Start testing */
Ecdb_Burn_Project *proj; Ecdb_Burn_Project *proj;
Ecdb_Source *src;
proj = ecdb_burn_project_new(); proj = ecdb_burn_project_new();
i = 1; i = 1;
while ((i < argc) && (argv)) while ((i < argc) && (argv))
{ {
/* No trailing slashes */
if (ecore_file_exists(argv[i])) if (ecore_file_exists(argv[i]))
{ {
if (ecore_file_is_dir(argv[i])) if (ecore_file_is_dir(argv[i]))
@ -52,10 +53,12 @@ main(int argc, char **argv)
src = ecdb_source_new(); src = ecdb_source_new();
ecdb_source_data_set(src, argv[i], ret); ecdb_source_data_set(src, argv[i], ret);
ecdb_source_child_append(proj->files, src); ecdb_source_child_append(proj->files, src);
ret = 0; ret = 0;
} }
i++; i++;
} }
proj->publisher_id = proj->data_preparer_id = proj->system_id = proj->publisher_id = proj->data_preparer_id = proj->system_id =
proj->application_id = proj->copywrite_id = proj->application_id = proj->copywrite_id =
proj->abstract_id = proj->biblio_id = "ecdb"; proj->abstract_id = proj->biblio_id = "ecdb";

View File

@ -44,6 +44,12 @@ ecdb_source_data_set(Ecdb_Source *src, const char *dst, unsigned char rec)
void void
ecdb_source_child_append(Ecdb_Source *src, Ecdb_Source *child) 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->num_children++;
src->children = realloc(src->children, sizeof(Ecdb_Source) * src->children = realloc(src->children, sizeof(Ecdb_Source) *
(src->num_children + 1)); (src->num_children + 1));
@ -54,8 +60,7 @@ ecdb_source_child_append(Ecdb_Source *src, Ecdb_Source *child)
void void
ecdb_source_add_children_rec(Ecdb_Source *parent, IsoImage *image) ecdb_source_add_children_rec(Ecdb_Source *parent, IsoImage *image)
{ {
IsoDir *cd; IsoDir *cd = NULL;
IsoNode *cn;
Ecdb_Source *cs; Ecdb_Source *cs;
int i; int i;
@ -65,27 +70,33 @@ ecdb_source_add_children_rec(Ecdb_Source *parent, IsoImage *image)
i = 0; i = 0;
while ((cs = parent->children[i])) while ((cs = parent->children[i]))
{ {
/* If recursive, let library add for us */
if (cs->rec) 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 (cs->num_children)
{ {
/* If not created above, make one here */ if (!cd)
if (!iso_tree_path_to_node(image, cs->dst, &cn))
{ {
iso_tree_add_new_dir(ISO_DIR(parent->node), iso_tree_add_new_dir(ISO_DIR(parent->node),
cs->dst, &cd); ecore_file_file_get(cs->dst), &cd);
cs->node = ISO_NODE(cd);
} }
else cs->node = ISO_NODE(cd);
cs->node = cn;
ecdb_source_add_children_rec(cs, image); ecdb_source_add_children_rec(cs, image);
} }
/* file */ /* file */
if ((!cs->rec) && (!cs->num_children)) if ((!cs->rec) && (!cs->num_children))
{
iso_tree_add_node(image, ISO_DIR(parent->node), iso_tree_add_node(image, ISO_DIR(parent->node),
cs->dst, NULL); cs->dst, NULL);
}
i++; i++;
} }
} }