~mdw
/
dvdrip
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
dvd-sector-copy.c: Force return to start of line on progress output.
[dvdrip]
/
dvd-sector-copy.c
diff --git
a/dvd-sector-copy.c
b/dvd-sector-copy.c
index
a43adb2
..
c6bad44
100644
(file)
--- a/
dvd-sector-copy.c
+++ b/
dvd-sector-copy.c
@@
-43,8
+43,8
@@
static int status = 0;
static void usage(FILE *fp)
{
fprintf(fp,
static void usage(FILE *fp)
{
fprintf(fp,
- "usage: %s [-c] [-
D DEV] [-R MAP]
"
-
"[-b OUTMAP] [-o OUTFILE] [-r [START]-[END]]
\n",
+ "usage: %s [-c] [-
R MAP] [-b OUTMAP] [-r [START]-[END]]\n
"
+
"\tDEVICE OUTFILE
\n",
prog);
}
prog);
}
@@
-285,7
+285,10
@@
static void put_title(dvd_reader_t *dvd, unsigned title)
static int progresslen = 0;
static void clear_progress_internal(void)
static int progresslen = 0;
static void clear_progress_internal(void)
- { while (progresslen) { fputs("\b \b", stdout); progresslen--; } }
+{
+ while (progresslen) { fputs("\b \b", stdout); progresslen--; }
+ putchar('\r');
+}
static void clear_progress(void)
{ clear_progress_internal(); fflush(stdout); }
static void vappend_progress(const char *fmt, va_list ap)
static void clear_progress(void)
{ clear_progress_internal(); fflush(stdout); }
static void vappend_progress(const char *fmt, va_list ap)
@@
-524,8
+527,7
@@
static void emit(secaddr start, secaddr end)
if (ferror(mapfp))
bail_syserr(errno, "error writing bad-sector map file");
}
if (ferror(mapfp))
bail_syserr(errno, "error writing bad-sector map file");
}
- if (outfd >= 0 &&
- lseek(outfd, (off_t)(bad_hi - bad_lo)*SECTORSZ, SEEK_CUR) < 0)
+ if (lseek(outfd, (off_t)(bad_hi - bad_lo)*SECTORSZ, SEEK_CUR) < 0)
bail_syserr(errno, "failed to seek past bad sectors");
status = 1;
}
bail_syserr(errno, "failed to seek past bad sectors");
status = 1;
}
@@
-646,9
+648,9
@@
int main(int argc, char *argv[])
uint64_t volsz;
secaddr pos;
off_t off;
uint64_t volsz;
secaddr pos;
off_t off;
- secaddr start, end;
+ secaddr start, end
, last
;
const struct event *ev;
const struct event *ev;
- const char *device
= "/dev/dvd", *outfile = 0
;
+ const char *device
, *outfile
;
int opt, blksz;
unsigned n;
size_t i;
int opt, blksz;
unsigned n;
size_t i;
@@
-667,16
+669,15
@@
int main(int argc, char *argv[])
p = strrchr(argv[0], '/'); prog = p ? p + 1 : argv[0];
for (;;) {
p = strrchr(argv[0], '/'); prog = p ? p + 1 : argv[0];
for (;;) {
- opt = getopt(argc, argv, "h
D:FR:b:co:
r:"); if (opt < 0) break;
+ opt = getopt(argc, argv, "h
FR:X:b:c
r:"); if (opt < 0) break;
switch (opt) {
case 'h': usage(stderr); exit(0);
switch (opt) {
case 'h': usage(stderr); exit(0);
- case 'D': device = optarg; break;
case 'F': f |= f_fixup; break;
case 'R':
fp = fopen(optarg, "r");
if (!fp)
bail_syserr(errno, "failed to open ranges file `%s'", optarg);
case 'F': f |= f_fixup; break;
case 'R':
fp = fopen(optarg, "r");
if (!fp)
bail_syserr(errno, "failed to open ranges file `%s'", optarg);
- i = 0;
+ i = 0;
last = -1;
for (;;) {
BUF_REWIND(&buf); if (read_line(fp, &buf)) break;
p = buf.p; i++;
for (;;) {
BUF_REWIND(&buf); if (read_line(fp, &buf)) break;
p = buf.p; i++;
@@
-686,8
+687,13
@@
int main(int argc, char *argv[])
(last <= SECLIMIT && start < last))
bail("bad range `%s' at `%s' line %zu", buf.p, optarg, i);
if (start < end) {
(last <= SECLIMIT && start < last))
bail("bad range `%s' at `%s' line %zu", buf.p, optarg, i);
if (start < end) {
- put_event(EV_WRITE, 0, start);
- put_event(EV_STOP, 0, end);
+ if (start == last)
+ eventq.v[eventq.n - 1].pos = end;
+ else {
+ put_event(EV_WRITE, 0, start);
+ put_event(EV_STOP, 0, end);
+ }
+ last = end;
}
}
if (ferror(fp))
}
}
if (ferror(fp))
@@
-698,7
+704,6
@@
int main(int argc, char *argv[])
mapfile = optarg;
break;
case 'c': f |= f_continue; break;
mapfile = optarg;
break;
case 'c': f |= f_continue; break;
- case 'o': outfile = optarg; break;
case 'r':
start = 0; end = -1;
if (parse_range(optarg, PRF_HYPHEN, &start, &end))
case 'r':
start = 0; end = -1;
if (parse_range(optarg, PRF_HYPHEN, &start, &end))
@@
-711,9
+716,11
@@
int main(int argc, char *argv[])
default: f |= f_bogus; break;
}
}
default: f |= f_bogus; break;
}
}
- if (
optind < argc
) f |= f_bogus;
+ if (
argc - optind != 2
) f |= f_bogus;
if (f&f_bogus) { usage(stderr); exit(2); }
if (f&f_bogus) { usage(stderr); exit(2); }
+ device = argv[optind]; outfile = argv[optind + 1];
+
dvdfd = open(device, O_RDONLY);
if (dvdfd < 0)
bail_syserr(errno, "failed to open device `%s'", device);
dvdfd = open(device, O_RDONLY);
if (dvdfd < 0)
bail_syserr(errno, "failed to open device `%s'", device);
@@
-743,7
+750,6
@@
int main(int argc, char *argv[])
}
if (f&f_continue) {
}
if (f&f_continue) {
- if (!outfile) bail("can't continue without output file");
off = lseek(outfd, 0, SEEK_END);
if (off < 0)
bail_syserr(errno, "failed to seek to end of output file `%s'",
off = lseek(outfd, 0, SEEK_END);
if (off < 0)
bail_syserr(errno, "failed to seek to end of output file `%s'",
@@
-846,8
+852,7
@@
int main(int argc, char *argv[])
break;
case EV_WRITE:
gettimeofday(&last_time, 0); last_pos = pos;
break;
case EV_WRITE:
gettimeofday(&last_time, 0); last_pos = pos;
- if (outfd >= 0 &&
- lseek(outfd, (off_t)ev->pos*SECTORSZ, SEEK_SET) < 0)
+ if (lseek(outfd, (off_t)ev->pos*SECTORSZ, SEEK_SET) < 0)
bail_syserr(errno,
"failed to seek to resume position "
"(sector %"PRIuSEC") in output file `%s'",
bail_syserr(errno,
"failed to seek to resume position "
"(sector %"PRIuSEC") in output file `%s'",
@@
-879,7
+884,7
@@
int main(int argc, char *argv[])
if (progresslen) putchar('\n');
if (progresslen) putchar('\n');
- if (
outfd >= 0 &&
ftruncate(outfd, (off_t)limit*SECTORSZ) < 0)
+ if (ftruncate(outfd, (off_t)limit*SECTORSZ) < 0)
bail_syserr(errno, "failed to set output file `%s' length", outfile);
if (dvd) DVDClose(dvd);
bail_syserr(errno, "failed to set output file `%s' length", outfile);
if (dvd) DVDClose(dvd);