From ed6ed5c1ce0854f1b8956a66e8a429c9d5ff3948 Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Thu, 15 Oct 2009 11:33:18 +0300 Subject: [PATCH] Add ftell() clone to FD_t --- rpmio/rpmio.c | 15 +++++++++++++++ rpmio/rpmio.h | 5 +++++ 2 files changed, 20 insertions(+) diff --git a/rpmio/rpmio.c b/rpmio/rpmio.c index 94747aa..1bc79da 100644 --- a/rpmio/rpmio.c +++ b/rpmio/rpmio.c @@ -2052,6 +2052,21 @@ int Fflush(FD_t fd) return 0; } +off_t Ftell(FD_t fd) +{ + FDIO_t iot; + off_t pos = -2; /* assume not implemented */ + + if (fd == NULL) return -1; + iot = fdGetIo(fd); + /* this wont work correctly for compressed types */ + if (iot == fpio || iot == fdio || iot == ufdio) { + pos = lseek(Fileno(fd), 0, SEEK_CUR); + } + + return pos; +} + int Ferror(FD_t fd) { int i, rc = 0; diff --git a/rpmio/rpmio.h b/rpmio/rpmio.h index ca05d15..a313371 100644 --- a/rpmio/rpmio.h +++ b/rpmio/rpmio.h @@ -65,6 +65,11 @@ ssize_t Fwrite(const void * buf, size_t size, size_t nmemb, FD_t fd); int Fseek(FD_t fd, _libio_off_t offset, int whence); /** \ingroup rpmio + * ftell(3) clone. + */ +off_t Ftell(FD_t fd); + +/** \ingroup rpmio * fclose(3) clone. */ int Fclose( FD_t fd); -- 2.7.4