Several directories and files in one session, added display of fifo

This commit is contained in:
Thomas Schmitt 2007-10-08 20:41:42 +00:00
parent a903d19024
commit cf2baa3a84
1 changed files with 56 additions and 23 deletions

View File

@ -13,6 +13,8 @@
#include <getopt.h>
#include <err.h>
#include <string.h>
#include <errno.h>
#include <sys/stat.h>
#include <libisofs/libisofs.h>
@ -30,18 +32,32 @@ extern int optind;
#define With_graft_poinT 1
static int graft_point(struct iso_volume *volume, const char *disc_path,
static int graft_point(struct iso_volume *volume, const char *disk_path,
const char *img_path, struct iso_tree_radd_dir_behavior *behav)
{
char path[4096], *apt, *npt;
struct iso_tree_node_dir *dir;
struct iso_tree_node *node;
int done= 0;
int done= 0, is_dir= 0;
struct stat stbuf;
strncpy(path, img_path, sizeof(path)-1);
path[sizeof(path)-1]= 0;
apt= npt= path;
if(lstat(disk_path, &stbuf) == -1) {
fprintf(stderr, "Cannot determine attributes of '%s' : %s (%d)\n",
disk_path, (errno > 0 ? strerror(errno) : "unknown error"), errno);
return(0);
}
if(S_ISDIR(stbuf.st_mode))
is_dir= 1;
else if(!(S_ISREG(stbuf.st_mode) || S_ISLNK(stbuf.st_mode))) {
fprintf(stderr, "File object '%s' is of non-supported file type\n",
disk_path);
return(0);
}
dir= iso_volume_get_root(volume);
if(dir==NULL) {
fprintf(stderr, "While grafting '%s' : no root node available\n", img_path);
@ -75,11 +91,21 @@ static int graft_point(struct iso_volume *volume, const char *disc_path,
return(0);
}
}
if(done)
iso_tree_radd_dir(dir, path, behav);
else
if(done) {
if(is_dir) {
iso_tree_radd_dir(dir, disk_path, behav);
} else {
node= iso_tree_add_node(dir, disk_path);
if(node == NULL) {
fprintf(stderr, "While grafting '%s'='%s' : libisofs_errno = %d\n",
img_path, disk_path, libisofs_errno);
}
}
} else
*npt= '/';
}
fprintf(stderr, "NOTE: added %s '%s'='%s'\n", (is_dir ? "directory" : "node"),
img_path, disk_path);
return(1);
}
@ -114,7 +140,9 @@ int main(int argc, char **argv)
int c;
struct iso_tree_radd_dir_behavior behav = {0,0,0};
int flags=0;
int ret=0;
int ret=0, i;
int size, free_bytes;
char *status_text;
while ((c = getopt(argc, argv, optstring)) != -1) {
switch(c) {
@ -189,10 +217,12 @@ int main(int argc, char **argv)
#ifdef With_graft_poinT
if (graft_point(iso_volset_get_volume(volset, 0),
argv[optind+1], argv[optind+1], &behav) <= 0) {
fprintf(stderr, "Canot graft '%s'\n", argv[optind+1]);
goto exit_cleanup;
for (i = optind + 1; i < argc; i++) {
if (graft_point(iso_volset_get_volume(volset, 0),
argv[i], argv[i], &behav) <= 0) {
fprintf(stderr, "Canot graft '%s'\n", argv[optind+1]);
goto exit_cleanup;
}
}
#else
@ -230,20 +260,11 @@ int main(int argc, char **argv)
{
struct burn_write_opts *burn_options;
struct burn_progress progress;
char reasons[BURN_REASONS_LEN];
burn_options = burn_write_opts_new(drive);
burn_drive_set_speed(drive, 0, 0);
burn_write_opts_set_underrun_proof(burn_options, 1);
if (burn_write_opts_auto_write_type(burn_options, disc,
reasons, 0) == BURN_WRITE_NONE) {
fprintf(stderr,
"Failed to find a suitable write mode:\n%s\n", reasons);
ret = 1;
goto volset_cleanup;
}
/* ok, write the new track */
isoburn_disc_write(burn_options, disc);
burn_write_opts_free(burn_options);
@ -251,8 +272,19 @@ int main(int argc, char **argv)
while (burn_drive_get_status(drive, NULL) == BURN_DRIVE_SPAWNING)
usleep(100002);
while (burn_drive_get_status(drive, &progress) != BURN_DRIVE_IDLE) {
printf("Writing: sector %d of %d\n", progress.sector, progress.sectors);
while (burn_drive_get_status(drive, &progress)
!= BURN_DRIVE_IDLE) {
printf("Writing: sector %d of %d",
progress.sector, progress.sectors);
ret = isoburn_get_fifo_status(drive, &size,
&free_bytes, &status_text);
if (ret > 0 )
printf(" [fifo %s, %2d%% fill]", status_text,
(int) (100.0 - 100.0 *
((double) free_bytes) /
(double) size));
printf("\n");
sleep(1);
}
}
@ -262,7 +294,8 @@ int main(int argc, char **argv)
if (isoburn_activate_session(drive) <= 0) {
fprintf(stderr, "Ups, new vol desc write failed\n");
}
ret= 0;
volset_cleanup:;
/*
iso_volset_free(volset);