Merging upstream version 1.2.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
844a3e48f2
commit
73f1304e10
19 changed files with 181 additions and 105 deletions
|
@ -1,6 +1,6 @@
|
|||
/* Plzip - Parallel compressor compatible with lzip
|
||||
Copyright (C) 2009 Laszlo Ersek.
|
||||
Copyright (C) 2009, 2010, 2011, 2012, 2013, 2014 Antonio Diaz Diaz.
|
||||
Copyright (C) 2009-2014 Antonio Diaz Diaz.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
@ -43,17 +43,17 @@
|
|||
int preadblock( const int fd, uint8_t * const buf, const int size,
|
||||
const long long pos )
|
||||
{
|
||||
int rest = size;
|
||||
int sz = 0;
|
||||
errno = 0;
|
||||
while( rest > 0 )
|
||||
while( sz < size )
|
||||
{
|
||||
const int n = pread( fd, buf + size - rest, rest, pos + size - rest );
|
||||
if( n > 0 ) rest -= n;
|
||||
const int n = pread( fd, buf + sz, size - sz, pos + sz );
|
||||
if( n > 0 ) sz += n;
|
||||
else if( n == 0 ) break; // EOF
|
||||
else if( errno != EINTR ) break;
|
||||
errno = 0;
|
||||
}
|
||||
return size - rest;
|
||||
return sz;
|
||||
}
|
||||
|
||||
|
||||
|
@ -63,16 +63,16 @@ int preadblock( const int fd, uint8_t * const buf, const int size,
|
|||
int pwriteblock( const int fd, const uint8_t * const buf, const int size,
|
||||
const long long pos )
|
||||
{
|
||||
int rest = size;
|
||||
int sz = 0;
|
||||
errno = 0;
|
||||
while( rest > 0 )
|
||||
while( sz < size )
|
||||
{
|
||||
const int n = pwrite( fd, buf + size - rest, rest, pos + size - rest );
|
||||
if( n > 0 ) rest -= n;
|
||||
const int n = pwrite( fd, buf + sz, size - sz, pos + sz );
|
||||
if( n > 0 ) sz += n;
|
||||
else if( n < 0 && errno != EINTR ) break;
|
||||
errno = 0;
|
||||
}
|
||||
return size - rest;
|
||||
return sz;
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue