From 519e3e01ae0d2ef2f00cd2ff441c91593356f4e9 Mon Sep 17 00:00:00 2001 From: John Reiser Date: Mon, 28 Mar 2011 10:12:36 -0700 Subject: [PATCH] OutputFile implements read() and readx(); beware --stdout. --- src/file.cpp | 16 ++++++++++++++++ src/file.h | 2 ++ 2 files changed, 18 insertions(+) diff --git a/src/file.cpp b/src/file.cpp index 8819a2eb..f0c88f60 100644 --- a/src/file.cpp +++ b/src/file.cpp @@ -410,6 +410,22 @@ void OutputFile::seek(off_t off, int whence) super::seek(off,whence); } +int OutputFile::read(void *buf, int len) +{ + InputFile infile; + infile.open(this->getName(), O_RDONLY); + infile.seek(this->tell(), SEEK_SET); + return infile.read(buf, len); +} + +int OutputFile::readx(void *buf, int len) +{ + InputFile infile; + infile.open(this->getName(), O_RDONLY); + infile.seek(this->tell(), SEEK_SET); + return infile.readx(buf, len); +} + void OutputFile::set_extent(off_t offset, off_t length) { super::set_extent(offset, length); diff --git a/src/file.h b/src/file.h index b245484e..bc6923aa 100644 --- a/src/file.h +++ b/src/file.h @@ -141,6 +141,8 @@ public: // FIXME - these won't work when using the '--stdout' option virtual void seek(off_t off, int whence); virtual void rewrite(const void *buf, int len); + virtual int read(void *buf, int len); + virtual int readx(void *buf, int len); // util static void dump(const char *name, const void *buf, int len, int flags=-1);