diff options
author | Eugene Sandulenko | 2016-10-26 19:00:13 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2016-10-26 19:00:13 +0200 |
commit | 3071bb40d8773b7c24cb87a11fc8b8ea73e6284b (patch) | |
tree | 8a88f118ca902cadf986d3954d1c1688ba0d1a5a /common | |
parent | f6dda6b7fbbba28d8aa1d396f9812471ed0e059d (diff) | |
download | scummvm-rg350-3071bb40d8773b7c24cb87a11fc8b8ea73e6284b.tar.gz scummvm-rg350-3071bb40d8773b7c24cb87a11fc8b8ea73e6284b.tar.bz2 scummvm-rg350-3071bb40d8773b7c24cb87a11fc8b8ea73e6284b.zip |
COMMON: Added debug method for printing out stream contents
Diffstat (limited to 'common')
-rw-r--r-- | common/stream.cpp | 13 | ||||
-rw-r--r-- | common/stream.h | 9 |
2 files changed, 22 insertions, 0 deletions
diff --git a/common/stream.cpp b/common/stream.cpp index a8446a9086..08774312fd 100644 --- a/common/stream.cpp +++ b/common/stream.cpp @@ -247,6 +247,19 @@ uint32 SafeSeekableSubReadStream::read(void *dataPtr, uint32 dataSize) { return SeekableSubReadStream::read(dataPtr, dataSize); } +void SeekableReadStream::hexdump(int len, int bytesPerLine, int startOffset) { + uint pos_ = pos(); + uint size_ = size(); + uint toRead = MIN<uint>(len + startOffset, size_ - pos_); + byte *data = (byte *)calloc(toRead, 1); + + read(data, toRead); + Common::hexdump(data, toRead, bytesPerLine, startOffset); + + free(data); + + seek(pos_); +} #pragma mark - diff --git a/common/stream.h b/common/stream.h index e0ffc47d7f..30107720dc 100644 --- a/common/stream.h +++ b/common/stream.h @@ -514,6 +514,15 @@ public: * err() or eos() to determine whether an exception occurred. */ virtual String readLine(); + + /** + * Print a hexdump of the stream while maintaing position. The number + * of bytes per line is customizable. + * @param len the length of that data + * @param bytesPerLine number of bytes to print per line (default: 16) + * @param startOffset shift the shown offsets by the starting offset (default: 0) + */ + void hexdump(int len, int bytesPerLine = 16, int startOffset = 0); }; /** |