1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
| int create_package(GtkWidget *pWidget, gpointer data)
{
const gchar *parm_tarbz2; //where is the tar.bz2 to convert ?
const gchar *parm_xml; //where is the xml to include in the package ?
const gchar *parm_configure; //is there any parameter to pass to ./configure ?
gchar *outdir;
int i;
gchar *command;
GtkWidget *pDialog;
outdir = (gchar*)malloc(sizeof(gchar) * strlen("/home/mik/Projects/fps_out/"));
debug("create_package : malloc ok");
strcpy(outdir,"/home/mik/Projects/fps_out/");
/* get all parameters */
parm_tarbz2 = gtk_entry_get_text(GTK_ENTRY(MainNew.entry1));
parm_xml = gtk_entry_get_text(GTK_ENTRY(MainNew.entry2));
parm_configure = gtk_entry_get_text(GTK_ENTRY(MainNew.entry3));
i = chdir(outdir);
switch(i)
{
case -1:
if(mkdir(outdir,0755)==-1)
{
pDialog = gtk_message_dialog_new(GTK_WINDOW(MainNew.wizard),
GTK_DIALOG_MODAL,
GTK_MESSAGE_INFO,
GTK_BUTTONS_OK,
"Impossible de créer le répertoire %s : veuillez vérifier vos droits", outdir);
gtk_dialog_run(GTK_DIALOG(pDialog));
gtk_widget_destroy(pDialog);
return 0;
}
break;
case EACCES:
pDialog = gtk_message_dialog_new(GTK_WINDOW(MainNew.wizard),
GTK_DIALOG_MODAL,
GTK_MESSAGE_INFO,
GTK_BUTTONS_OK,
"Impossible d'accéder au répertoire %s : veuillez vérifier vos droits", outdir);
gtk_dialog_run(GTK_DIALOG(pDialog));
gtk_widget_destroy(pDialog);
return 0;
break;
case 0:
debug("create_package : chdir ok");
break;
}
//command = (gchar*)malloc(sizeof(gchar) * (strlen("tar xfj ")+strlen(parm_tarbz2)));
//strcpy(command, "tar xfj ");
//strcat(command, parm_tarbz2);
//system(command);
//g_print(command);
i = execlp("tar", "tar","xfj", parm_tarbz2, NULL);
return 1;
} |
Partager