From d962e8d2d650c7b297dcd041b55060bc29996a93 Mon Sep 17 00:00:00 2001 From: Pixel Date: Thu, 15 Aug 2002 22:09:26 +0000 Subject: bleeeeh --- generic/Handle.cpp | 14 ++++++++++++++ generic/Input.cpp | 7 +++++-- generic/Makefile | 2 +- includes/Handle.h | 6 ++++++ 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/generic/Handle.cpp b/generic/Handle.cpp index 6390a6d..29b4816 100644 --- a/generic/Handle.cpp +++ b/generic/Handle.cpp @@ -149,6 +149,7 @@ void Handle::close() throw (GeneralException) { } if (h >= 0) { +#ifdef HAVE_ZLIB if (z) { // cerr << "Performing gzclose on handle " << h << endl; int err = gzclose(zfile); @@ -161,6 +162,9 @@ void Handle::close() throw (GeneralException) { } } } else { +#else + { +#endif int err = ::close(h); if (err) { throw GeneralException(String(_("Error during close: ")) + strerror(errno)); @@ -204,6 +208,7 @@ void Handle::Dup(const Handle & H) { } } +#ifdef HAVE_ZLIB void Handle::SetZ(int az) throw (GeneralException) { if (z) { throw GeneralException(_("Can't SetZ a Handle twice.")); @@ -229,8 +234,10 @@ void Handle::SetZ(int az) throw (GeneralException) { z = az; } } +#endif ssize_t Handle::uwrite(const void * buf, size_t count) throw (GeneralException) { +#ifdef HAVE_ZLIB if (z) { itell += count; // cerr << "Performing gzwrite of " << count << " byte for handle " << h << endl; @@ -246,12 +253,16 @@ ssize_t Handle::uwrite(const void * buf, size_t count) throw (GeneralException) } return err; } else { +#else + { +#endif itell += count = ::write(h, buf, count); return count; } } ssize_t Handle::uread(void * buf, size_t count) { +#ifdef HAVE_ZLIB if (z) { itell += count; // cerr << "Performing gzread of " << count << " byte for handle " << h << endl; @@ -267,6 +278,9 @@ ssize_t Handle::uread(void * buf, size_t count) { } return err; } else { +#else + { +#endif itell += count = ::read(h, buf, count); return count; } diff --git a/generic/Input.cpp b/generic/Input.cpp index ffef9f0..1cb6e2e 100644 --- a/generic/Input.cpp +++ b/generic/Input.cpp @@ -61,10 +61,13 @@ time_t Input::GetModif() { return date_modif; } -off_t Input::seek(off_t offset, int whence) { - itell = lseek(GetHandle(), offset, whence); +off_t Input::seek(off_t offset, int whence) throw (GeneralException) { + if ((itell = lseek(GetHandle(), offset, whence)) < 0) { + throw IOGereral(String(_("Error seeking file ")) + no + _(": ") + strerror(errno)); + } #ifdef PARANOID_SEEK if (itell != lseek(GetHandle(), 0, SEEK_CUR)) { + throw IOGereral(String(_("Error seeking file ")) + no + _(": the position does not match")); } #endif } diff --git a/generic/Makefile b/generic/Makefile index 98317b8..8bc6a49 100755 --- a/generic/Makefile +++ b/generic/Makefile @@ -1,6 +1,6 @@ #!/usr/bin/make -f -CPPFLAGS=-Wall -g -O3 -mcpu=i686 -pedantic -pedantic-errors -I../includes +CPPFLAGS=-Wall -g -O3 -mcpu=i686 -pedantic -pedantic-errors -I../includes -DPARANOID_SEEK -DHAVE_ZLIB CXX=g++ OBJECTS = Buffer.o Exceptions.o Handle.o Image.o Input.o Output.o generic.o fileutils.o String.o diff --git a/includes/Handle.h b/includes/Handle.h index 967e221..3836f3e 100644 --- a/includes/Handle.h +++ b/includes/Handle.h @@ -2,7 +2,9 @@ #define __HANDLE_H__ #ifdef __cplusplus +#ifdef HAVE_ZLIB #include +#endif #include #include #include @@ -32,7 +34,9 @@ class Handle : public Base { int GetHandle(); virtual bool CanWatch(); virtual void Dup(const Handle &); +#ifdef HAVE_ZLIB virtual void SetZ(int) throw (GeneralException); +#endif protected: Handle(int h); off_t itell; @@ -41,8 +45,10 @@ class Handle : public Base { ssize_t uread(void *, size_t); int h; bool closed, nonblock; +#ifdef HAVE_ZLIB gzFile zfile; int z; +#endif }; Handle & operator<<(Handle &, const String &); -- cgit v1.2.3