summaryrefslogtreecommitdiff
path: root/test/run_gunzip.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2015-12-16 11:05:33 +0100
committerMax Kellermann <max@duempel.org>2015-12-18 01:08:16 +0100
commite6e7d6dbd654b9936b04f27b8153fb4ed945b9d3 (patch)
treeae4f965fd7a24ce01aad50117a5776610c861af6 /test/run_gunzip.cxx
parentfe60c52c70705b721bee7fbd6e3aae076a3b99c9 (diff)
fs/io/Reader: use C++ exceptions instead of class Error
Diffstat (limited to 'test/run_gunzip.cxx')
-rw-r--r--test/run_gunzip.cxx31
1 files changed, 13 insertions, 18 deletions
diff --git a/test/run_gunzip.cxx b/test/run_gunzip.cxx
index 114fab3e5..469b68ba5 100644
--- a/test/run_gunzip.cxx
+++ b/test/run_gunzip.cxx
@@ -28,32 +28,32 @@
#include <stdlib.h>
#include <unistd.h>
-static bool
-Copy(OutputStream &dest, Reader &src, Error &error)
+static void
+Copy(OutputStream &dest, Reader &src)
{
while (true) {
char buffer[4096];
- size_t nbytes = src.Read(buffer, sizeof(buffer), error);
+ size_t nbytes = src.Read(buffer, sizeof(buffer));
if (nbytes == 0)
- return !error.IsDefined();
+ break;
dest.Write(buffer, nbytes);
}
}
-static bool
-CopyGunzip(OutputStream &dest, Reader &_src, Error &error)
+static void
+CopyGunzip(OutputStream &dest, Reader &_src)
{
- GunzipReader src(_src, error);
- return src.IsDefined() && Copy(dest, src, error);
+ GunzipReader src(_src);
+ Copy(dest, src);
}
-static bool
-CopyGunzip(FILE *_dest, Path src_path, Error &error)
+static void
+CopyGunzip(FILE *_dest, Path src_path)
{
StdioOutputStream dest(_dest);
- FileReader src(src_path, error);
- return src.IsDefined() && CopyGunzip(dest, src, error);
+ FileReader src(src_path);
+ CopyGunzip(dest, src);
}
int
@@ -67,12 +67,7 @@ main(int argc, gcc_unused char **argv)
Path path = Path::FromFS(argv[1]);
try {
- Error error;
- if (!CopyGunzip(stdout, path, error)) {
- fprintf(stderr, "%s\n", error.GetMessage());
- return EXIT_FAILURE;
- }
-
+ CopyGunzip(stdout, path);
return EXIT_SUCCESS;
} catch (const std::exception &e) {
LogError(e);