From cbd2fd34a0d267348da3d7b6c924cde0dbec2c9c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 2 Dec 2017 11:51:37 +0100 Subject: [PATCH] - added seeking capabilities to FileWriter class. --- src/files.cpp | 24 ++++++++++++++++++++++++ src/files.h | 2 ++ 2 files changed, 26 insertions(+) diff --git a/src/files.cpp b/src/files.cpp index 0de13e8ea..5bcc3d7bb 100644 --- a/src/files.cpp +++ b/src/files.cpp @@ -634,6 +634,30 @@ size_t FileWriter::Write(const void *buffer, size_t len) } } +long FileWriter::Tell() +{ + if (File != NULL) + { + return ftell(File); + } + else + { + return 0; + } +} + +long FileWriter::Seek(long offset, int mode) +{ + if (File != NULL) + { + return fseek(File, offset, mode); + } + else + { + return 0; + } +} + size_t FileWriter::Printf(const char *fmt, ...) { diff --git a/src/files.h b/src/files.h index 4c73273a1..94255b1a0 100644 --- a/src/files.h +++ b/src/files.h @@ -409,6 +409,8 @@ public: static FileWriter *Open(const char *filename); virtual size_t Write(const void *buffer, size_t len); + virtual long Tell(); + virtual long Seek(long offset, int mode); size_t Printf(const char *fmt, ...) GCCPRINTF(2,3); protected: