Added read() functions that take a MemBuffer as arg.

committer: mfx <mfx> 1035297017 +0000
This commit is contained in:
Markus F.X.J. Oberhumer 2002-10-22 14:30:17 +00:00
parent b082a6f1da
commit 7af193df77
2 changed files with 36 additions and 6 deletions

View File

@ -28,6 +28,7 @@
#include "conf.h"
#include "file.h"
#include "mem.h"
/*************************************************************************
@ -236,24 +237,47 @@ void InputFile::sopen(const char *name, int flags, int shflags)
if (!isOpen())
{
if (errno == ENOENT)
throw FileNotFoundException(_name,errno);
throw FileNotFoundException(_name, errno);
else if (errno == EEXIST)
throw FileAlreadyExistsException(_name,errno);
throw FileAlreadyExistsException(_name, errno);
else
throwIOException(_name,errno);
throwIOException(_name, errno);
}
}
int InputFile::read(void *buf, int len)
{
return super::read(buf,len);
return super::read(buf, len);
}
int InputFile::readx(void *buf, int len)
{
return super::readx(buf,len);
return super::readx(buf, len);
}
int InputFile::read(MemBuffer *buf, int len)
{
assert((unsigned)len <= buf->getSize());
return super::read(buf->getVoidPtr(), len);
}
int InputFile::readx(MemBuffer *buf, int len)
{
assert((unsigned)len <= buf->getSize());
return super::readx(buf->getVoidPtr(), len);
}
int InputFile::read(MemBuffer &buf, int len)
{
return read(&buf, len);
}
int InputFile::readx(MemBuffer &buf, int len)
{
return readx(&buf, len);
}

View File

@ -29,6 +29,8 @@
#ifndef __UPX_FILE_H
#define __UPX_FILE_H
class MemBuffer;
/*************************************************************************
//
@ -92,6 +94,10 @@ public:
virtual int read(void *buf, int len);
virtual int readx(void *buf, int len);
virtual int read(MemBuffer *buf, int len);
virtual int readx(MemBuffer *buf, int len);
virtual int read(MemBuffer &buf, int len);
virtual int readx(MemBuffer &buf, int len);
virtual void seek(off_t off, int whence);
virtual off_t tell() const;