More work with regards to imager

This commit is contained in:
Jaime Thomas 2008-05-21 01:01:37 +00:00
parent 1fecc24f2a
commit 7cff99ed50
5 changed files with 54 additions and 84 deletions

View File

@ -13,6 +13,7 @@ main(int argc, char **argv)
{
int i;
int ret = 0;
Ecdb_Source *src;
if (!ecore_init())
{
@ -44,7 +45,15 @@ main(int argc, char **argv)
i = 1;
while ((i < argc) && (argv))
{
ecore_list_append(proj->files, strdup(argv[i]));
if (ecore_file_exists(argv[i]))
{
if (ecore_file_is_dir(argv[i]))
ret = 1;
src = ecdb_source_new();
ecdb_source_data_set(src, argv[i], ret);
ecdb_source_child_append(proj->files, src);
ret = 0;
}
i++;
}
proj->simulate = TRUE;

View File

@ -46,7 +46,7 @@ ecdb_burn_project_init(Ecdb_Burn_Project *proj)
proj->underrun_proof = TRUE;
proj->opc = TRUE;
proj->multi = TRUE;
proj->files = ecore_list_new();
proj->files = ecdb_source_new();
return TRUE;
}
@ -311,7 +311,7 @@ ecdb_burn_finished(void *data, int type, void *event)
/* To be removed from here at some point */
Ecdb_Burn_Project *t;
t = ECDB_BURN(proj->proj);
ecore_list_destroy(t->files);
FREE(t->files);
FREE(t);
FREE(proj);
ecore_event_add(ECORE_EVENT_SIGNAL_EXIT, NULL, NULL, NULL);

View File

@ -50,6 +50,19 @@ struct _Ecdb_Project_Info
BurnDriveStatus stat;
};
/* Typecast a pointer to an Ecdb_Source */
#define ECDB_SOURCE(src) ((Ecdb_Source *) src)
typedef struct _Ecdb_Source Ecdb_Source;
struct _Ecdb_Source
{
const char *dst;
unsigned char rec:1;
unsigned char num_children;
Ecdb_Source **children;
IsoNode *node;
};
/* Typecast a pointer to an Ecdb_Project */
#define ECDB_PROJECT(proj) ((Ecdb_Project *) proj)
@ -60,7 +73,7 @@ struct _Ecdb_Burn_Project
Ecdb_Project proj;
/* Files are important here */
Ecore_List *files;
Ecdb_Source *files;
/* Ids */
char *volume_id;
@ -111,17 +124,4 @@ struct _Ecdb_Erase_Project
/* Typecast a pointer to an Ecdb_Erase_Project */
#define ECDB_ERASE(proj) ((Ecdb_Erase_Project *) proj)
/* Typecast a pointer to an Ecdb_Source */
#define ECDB_SOURCE(src) ((Ecdb_Source *) src)
typedef struct _Ecdb_Source Ecdb_Source;
struct _Ecdb_Source
{
const char *dst;
unsigned char rec:1;
unsigned char num_children;
Ecdb_Source **children;
IsoNode *node;
};
#endif

View File

@ -89,48 +89,43 @@ ecdb_source_add_children_rec(Ecdb_Source *parent, IsoImage *image)
i++;
}
}
/* Deprecated code */
/* Some limitations here need to be worked out
* Handle: audio, etc */
/* proj->files should only have children */
BurnSource *
ecdb_image_project(Ecdb_Burn_Project *proj)
{
IsoImage *image;
IsoDir *root;
Ecdb_Source *c;
IsoWriteOpts *opts;
BurnSource *data_src, *fifo_src;
char *path;
int ret;
efreet_mime_init();
if ((!proj->files) || (ecore_list_empty_is(proj->files)))
if ((!proj->files) || (!proj->files->dst))
return NULL;
else if (ecore_list_count(proj->files) == 1)
/* To handle already-suplied image files */
efreet_mime_init();
if (proj->files->num_children == 1)
{
path = ecore_list_first(proj->files);
if ((path) && (!ecore_file_is_dir(path)) &&
(!strcmp(efreet_mime_type_get(path),
efreet_mime_init();
c = proj->files->children[0];
if ((!ecore_file_is_dir(c->dst)) &&
(!strcmp(efreet_mime_type_get(c->dst),
"application/x-cd-image")))
{
path = ecore_list_first_remove(proj->files);
data_src = burn_file_source_new(path, NULL);
FREE(path);
data_src = burn_file_source_new(c->dst, NULL);
goto FIFO_CREATE;
}
efreet_mime_shutdown();
}
ret = iso_image_new(proj->volume_id, &image);
if (!ret)
/* Otherwise we have a bunch of files */
if (!iso_image_new(proj->volume_id, &image))
{
printf("Failed to create an iso image!\n");
iso_finish();
printf("Failed to create image!\n");
return NULL;
}
/* Disk ids */
/* Set all ids */
if (proj->publisher_id)
iso_image_set_publisher_id(image, proj->publisher_id);
if (proj->data_preparer_id)
@ -147,72 +142,38 @@ ecdb_image_project(Ecdb_Burn_Project *proj)
if (proj->biblio_id)
iso_image_set_biblio_file_id(image, proj->biblio_id);
/* Write Options - default to distribution for now */
ret = iso_write_opts_new(&opts, 2);
if (!ret)
if (!iso_write_opts_new(&opts, 2))
{
printf("Failed to create writing options!\n");
iso_image_unref(image);
iso_finish();
return NULL;
}
/* Most set by default with 2 ^ */
/* And some write opts stuff */
iso_write_opts_set_iso_level(opts, proj->iso_level);
iso_write_opts_set_joliet(opts, proj->use_joliet);
iso_write_opts_set_rockridge(opts, proj->use_rockridge);
iso_write_opts_set_iso1999(opts, proj->iso1990);
//iso_write_opts_set_appendable(opts, proj->appendable);
iso_write_opts_set_appendable(opts, proj->multi);
iso_tree_set_follow_symlinks(image, proj->follow_symlinks);
iso_tree_set_ignore_hidden(image, proj->ignore_hidden);
iso_tree_set_ignore_special(image, proj->ignore_special);
root = iso_image_get_root(image);
ecore_list_first_goto(proj->files);
ret = 0;
while ((path = ecore_list_remove(proj->files)))
{
/* For now just this, in future special, symlink */
if (ecore_file_is_dir(path))
iso_tree_add_dir_rec(image, root, path);
else if (ecore_file_exists(path))
iso_tree_add_node(image, root, path, NULL);
else
{
FREE(path);
continue;
}
FREE(path);
ret++;
}
if (!ret)
{
printf("No files appended to image!\n");
iso_image_unref(image);
iso_write_opts_free(opts);
iso_finish();
return NULL;
}
/* actually fill image with some files now */
proj->files->node = ISO_NODE(iso_image_get_root(image));
ecdb_source_add_children_rec(proj->files, image);
/* Make the burn source here */
iso_image_create_burn_source(image, opts, &data_src);
iso_write_opts_free(opts);
iso_image_unref(image);
FIFO_CREATE:
/* And, convert to fifo */
FIFO_CREATE:
fifo_src = burn_fifo_source_new(data_src,
proj->fifo_chunksize, proj->fifo_chunks, 0);
burn_source_free(data_src);
/* I can't call this now, as it destroys the libiso_msgr before the
* library is finished - I'll just init and finish once...
*/
//iso_finish();
efreet_mime_shutdown();
return fifo_src;
}

View File

@ -33,7 +33,7 @@ ecdb_shutdown(void *data, int type, void *event)
ecore_list_destroy(em->drives);
free(em);
ecore_main_loop_quit();
return 0;
return FALSE;
}
void