Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
db6c0d54
Commit
db6c0d54
authored
Nov 10, 2016
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test/run_gzip: migrate from class Error to C++ exceptions
parent
a17abc55
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
23 deletions
+14
-23
run_gzip.cxx
test/run_gzip.cxx
+14
-23
No files found.
test/run_gzip.cxx
View file @
db6c0d54
...
...
@@ -20,47 +20,43 @@
#include "config.h"
#include "fs/io/GzipOutputStream.hxx"
#include "fs/io/StdioOutputStream.hxx"
#include "system/Error.hxx"
#include "Log.hxx"
#include "util/Error.hxx"
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
static
bool
Copy
(
OutputStream
&
dest
,
int
src
,
Error
&
error
)
static
void
Copy
(
OutputStream
&
dest
,
int
src
)
{
while
(
true
)
{
char
buffer
[
4096
];
ssize_t
nbytes
=
read
(
src
,
buffer
,
sizeof
(
buffer
));
if
(
nbytes
<=
0
)
{
if
(
nbytes
<
0
)
{
error
.
SetErrno
();
return
false
;
}
else
return
true
;
if
(
nbytes
<
0
)
throw
MakeErrno
(
"read() failed"
);
return
;
}
dest
.
Write
(
buffer
,
nbytes
);
}
}
static
bool
CopyGzip
(
OutputStream
&
_dest
,
int
src
,
Error
&
error
)
static
void
CopyGzip
(
OutputStream
&
_dest
,
int
src
)
{
GzipOutputStream
dest
(
_dest
);
if
(
!
Copy
(
dest
,
src
,
error
))
return
false
;
Copy
(
dest
,
src
);
dest
.
Flush
();
return
true
;
}
static
bool
CopyGzip
(
FILE
*
_dest
,
int
src
,
Error
&
error
)
static
void
CopyGzip
(
FILE
*
_dest
,
int
src
)
{
StdioOutputStream
dest
(
_dest
);
return
CopyGzip
(
dest
,
src
,
error
);
CopyGzip
(
dest
,
src
);
}
int
...
...
@@ -72,12 +68,7 @@ main(int argc, gcc_unused char **argv)
}
try
{
Error
error
;
if
(
!
CopyGzip
(
stdout
,
STDIN_FILENO
,
error
))
{
fprintf
(
stderr
,
"%s
\n
"
,
error
.
GetMessage
());
return
EXIT_FAILURE
;
}
CopyGzip
(
stdout
,
STDIN_FILENO
);
return
EXIT_SUCCESS
;
}
catch
(
const
std
::
exception
&
e
)
{
LogError
(
e
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment