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 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";

View File

@ -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++;
}
}