mirror of
https://github.com/upx/upx
synced 2025-09-28 19:06:07 +08:00
Fixed partial reads.
committer: mfx <mfx> 1084308720 +0000
This commit is contained in:
parent
b10f68d20a
commit
06f8c55908
42
src/file.cpp
42
src/file.cpp
|
@ -128,29 +128,13 @@ void FileBase::closex()
|
||||||
|
|
||||||
int FileBase::read(void *buf, int len)
|
int FileBase::read(void *buf, int len)
|
||||||
{
|
{
|
||||||
int l;
|
|
||||||
if (!isOpen() || len < 0)
|
if (!isOpen() || len < 0)
|
||||||
throwIOException("bad read");
|
throwIOException("bad read");
|
||||||
if (len == 0)
|
errno = 0;
|
||||||
return 0;
|
long l = acc_safe_hread(_fd, buf, len);
|
||||||
for (;;)
|
if (errno)
|
||||||
{
|
|
||||||
#if defined(__DJGPP__)
|
|
||||||
l = ::_read(_fd, buf, len);
|
|
||||||
#else
|
|
||||||
l = ::read(_fd, buf, len);
|
|
||||||
#endif
|
|
||||||
if (l < 0)
|
|
||||||
{
|
|
||||||
#if defined(EINTR)
|
|
||||||
if (errno == EINTR)
|
|
||||||
continue;
|
|
||||||
#endif
|
|
||||||
throwIOException("read error",errno);
|
throwIOException("read error",errno);
|
||||||
}
|
return (int) l;
|
||||||
break;
|
|
||||||
}
|
|
||||||
return l;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -165,26 +149,12 @@ int FileBase::readx(void *buf, int len)
|
||||||
|
|
||||||
void FileBase::write(const void *buf, int len)
|
void FileBase::write(const void *buf, int len)
|
||||||
{
|
{
|
||||||
int l;
|
|
||||||
if (!isOpen() || len < 0)
|
if (!isOpen() || len < 0)
|
||||||
throwIOException("bad write");
|
throwIOException("bad write");
|
||||||
if (len == 0)
|
errno = 0;
|
||||||
return;
|
long l = acc_safe_hwrite(_fd, buf, len);
|
||||||
for (;;)
|
|
||||||
{
|
|
||||||
#if defined(__DJGPP__)
|
|
||||||
l = ::_write(_fd,buf,len);
|
|
||||||
#else
|
|
||||||
l = ::write(_fd,buf,len);
|
|
||||||
#endif
|
|
||||||
#if defined(EINTR)
|
|
||||||
if (l < 0 && errno == EINTR)
|
|
||||||
continue;
|
|
||||||
#endif
|
|
||||||
if (l != len)
|
if (l != len)
|
||||||
throwIOException("write error",errno);
|
throwIOException("write error",errno);
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
#else
|
#else
|
||||||
# include "acc/acc_inci.h"
|
# include "acc/acc_inci.h"
|
||||||
# include "acc/acclib/misc.ch"
|
# include "acc/acclib/misc.ch"
|
||||||
|
# include "acc/acclib/hsread.ch"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user