Control the number of sectors read in one go
This commit is contained in:
parent
a40fec50a8
commit
22721dee24
3 changed files with 17 additions and 11 deletions
|
|
@ -39,13 +39,6 @@
|
|||
#include <regex.h>
|
||||
|
||||
|
||||
|
||||
#define BUF_BLOCK_SIZE 128
|
||||
#define BUF_SIZE (BUF_BLOCK_SIZE * 2048)
|
||||
|
||||
int debug = 1;
|
||||
|
||||
|
||||
std::string BadSectors::toString() const
|
||||
{
|
||||
char buffer[1024];
|
||||
|
|
@ -73,7 +66,7 @@ bool BadSectors::tryMerge(const BadSectors & follower)
|
|||
//////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
DVDCopy::DVDCopy() : badSectors(NULL)
|
||||
DVDCopy::DVDCopy() : badSectors(NULL), sectorsRead(128)
|
||||
{
|
||||
reader = NULL;
|
||||
}
|
||||
|
|
@ -87,7 +80,7 @@ int DVDCopy::copyFile(const DVDFileData * dat, int firstBlock,
|
|||
/// fine)
|
||||
|
||||
if(readNumber < 0)
|
||||
readNumber = BUF_BLOCK_SIZE;
|
||||
readNumber = sectorsRead;
|
||||
|
||||
// First, looking for duplicates:
|
||||
if(dat->dup) {
|
||||
|
|
@ -295,7 +288,7 @@ void DVDCopy::scanForBadSectors(const char *device,
|
|||
registerBadSectors(dat, blk, nb, true);
|
||||
};
|
||||
|
||||
file->walkFile(0, sz, 128,
|
||||
file->walkFile(0, sz, sectorsRead,
|
||||
success, failure);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -77,6 +77,7 @@ class DVDCopy {
|
|||
/// In the hope to be read again...
|
||||
FILE * badSectors;
|
||||
|
||||
|
||||
/// Writes a bad sector list to the bad sectors file (unless
|
||||
/// dontWrite is true), and add them to the badSectors list (in any
|
||||
/// case).
|
||||
|
|
@ -138,6 +139,10 @@ public:
|
|||
/// Attempts to eject the drive.
|
||||
void ejectDrive();
|
||||
|
||||
/// Number of sectors read in one go (in the normal operations)
|
||||
int sectorsRead;
|
||||
|
||||
|
||||
~DVDCopy();
|
||||
};
|
||||
|
||||
|
|
|
|||
10
src/main.cc
10
src/main.cc
|
|
@ -36,6 +36,7 @@ void printHelp(const char * progname)
|
|||
<< "Options: \n"
|
||||
<< " -h, --help: print this help message\n"
|
||||
<< " -l, --list: list files contained on the DVD\n"
|
||||
<< " -n, --number NB: read NB sectors at a time\n"
|
||||
<< " -s, --second-pass: run a second pass reading only bad sectors\n"
|
||||
<< " -b, --bad-sectors: specify an alternate bad sectors file\n"
|
||||
<< " -S, --scan: scan directory for bad sectors\n"
|
||||
|
|
@ -47,6 +48,7 @@ static struct option long_options[] = {
|
|||
{ "help", 0, NULL, 'h'},
|
||||
{ "eject", 0, NULL, 'e' },
|
||||
{ "list", 1, NULL, 'l' },
|
||||
{ "number", 1, NULL, 'n' },
|
||||
{ "second-pass", 0, NULL, 's' },
|
||||
{ "bad-sectors", 1, NULL, 'b' },
|
||||
{ "scan", 0, NULL, 'S' },
|
||||
|
|
@ -63,7 +65,7 @@ int main(int argc, char ** argv)
|
|||
int eject = 0;
|
||||
|
||||
do {
|
||||
option = getopt_long(argc, argv, "b:hel:sS",
|
||||
option = getopt_long(argc, argv, "b:hel:sSn:",
|
||||
long_options, NULL);
|
||||
|
||||
switch(option) {
|
||||
|
|
@ -77,6 +79,12 @@ int main(int argc, char ** argv)
|
|||
case 'b':
|
||||
dvd.setBadSectorsFileName(optarg);
|
||||
break;
|
||||
case 'n': {
|
||||
int nb = atoi(optarg);
|
||||
if(nb > 0)
|
||||
dvd.sectorsRead = nb;
|
||||
}
|
||||
break;
|
||||
case 'l':
|
||||
{
|
||||
DVDReader dvd(optarg);
|
||||
|
|
|
|||
Loading…
Reference in a new issue