iotest.cpp polishing.
This commit is contained in:
parent
83cab13ae1
commit
c64f2e8ea1
@ -70,36 +70,33 @@ int main(int argc, char* const argv[])
|
||||
if ( argc >= 5 ) {
|
||||
int blocksize = argc==6 ? atoi(ba) : 10000;
|
||||
// ensure blocksize is sane
|
||||
if (blocksize<1) blocksize=1 ;
|
||||
if (blocksize>1024*1024) blocksize=10000;
|
||||
Exiv2::byte* bytes = new Exiv2::byte[blocksize];
|
||||
Exiv2::byte* bytes = blocksize>0 ? new Exiv2::byte[blocksize]: NULL;
|
||||
|
||||
// copy fileIn from a remote location.
|
||||
FILE* f = fopen(f0,"wb");
|
||||
if ( !f ) {
|
||||
Error(Exiv2::kerFileOpenFailed, f0, "w+b", strError());
|
||||
}
|
||||
BasicIo::AutoPtr io = Exiv2::ImageFactory::createIo(fr);
|
||||
io->open();
|
||||
if ( io->open() != 0 ) {
|
||||
Error(Exiv2::kerFileOpenFailed, io->path(), "rb", strError());
|
||||
}
|
||||
FileIo output(f0);
|
||||
if ( !output.open("wb") ) {
|
||||
Error(Exiv2::kerFileOpenFailed, output.path() , "w+b", strError());
|
||||
}
|
||||
size_t l = 0;
|
||||
if ( blocksize > 1 ) {
|
||||
if ( bytes ) {
|
||||
int r ;
|
||||
while ( (r=io->read(bytes,blocksize)) > 0 ) {
|
||||
l += r;
|
||||
fwrite(bytes,r,1,f) ;
|
||||
output.write(bytes,r) ;
|
||||
}
|
||||
} else {
|
||||
// blocksize == 1, read/write byte-wise (#1029)
|
||||
// read/write byte-wise (#1029)
|
||||
while ( l++ < io->size() ) {
|
||||
bytes[0] = io->getb();
|
||||
fwrite(bytes,1,1,f) ;
|
||||
output.putb(io->getb()) ;
|
||||
}
|
||||
}
|
||||
delete [] bytes;
|
||||
fclose(f);
|
||||
if ( !l ) {
|
||||
Error(Exiv2::kerFileOpenFailed, fr, "rb", strError());
|
||||
}
|
||||
if ( bytes ) delete [] bytes;
|
||||
output.close();
|
||||
}
|
||||
|
||||
FileIo fileIn(f0);
|
||||
|
||||
@ -35,7 +35,7 @@ if [ "$EXIV2_PORT" != "None" -a "$EXIV2_HTTP" != "None" ]; then
|
||||
if [ ! -z $exiv2_httpServer ]; then
|
||||
( cd "${testdir}"
|
||||
>&2 printf "*** HTTP tests begin\n"
|
||||
|
||||
|
||||
cd "$testdir"
|
||||
test_files="table.jpg Reagan.tiff exiv2-bug922a.jpg"
|
||||
for i in $test_files; do
|
||||
@ -44,11 +44,11 @@ if [ "$EXIV2_PORT" != "None" -a "$EXIV2_HTTP" != "None" ]; then
|
||||
runTest exiv2 -g City -g DateTime $t
|
||||
done
|
||||
done
|
||||
|
||||
runTest iotest s0 s1 s2 $exiv2_url/data/table.jpg 1 ; sniff
|
||||
|
||||
runTest iotest s0 s1 s2 $exiv2_url/data/table.jpg 0 ; sniff
|
||||
runTest iotest s0 s1 s2 $exiv2_url/data/table.jpg 10 ; sniff
|
||||
runTest iotest s0 s1 s2 $exiv2_url/data/table.jpg 1000 ; sniff
|
||||
|
||||
|
||||
>&2 printf "*** HTTP tests end\n"
|
||||
) | tr -d '\r' | sed 's/[ \t]+$//' > $results
|
||||
reportTest
|
||||
|
||||
Loading…
Reference in New Issue
Block a user