summaryrefslogtreecommitdiff
path: root/generic
diff options
context:
space:
mode:
Diffstat (limited to 'generic')
-rw-r--r--generic/Handle.cpp14
-rw-r--r--generic/Input.cpp7
-rwxr-xr-xgeneric/Makefile2
3 files changed, 20 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