1 |
< |
// Gzip Writer |
1 |
> |
// Zlib Error |
2 |
|
// |
3 |
|
// Douglas Thrift |
4 |
|
// |
5 |
|
// $Id$ |
6 |
|
|
7 |
< |
#ifndef _GzipWriter_hpp_ |
8 |
< |
#define _GzipWriter_hpp_ |
7 |
> |
#ifndef _Zlib_Error_hpp_ |
8 |
> |
#define _Zlib_Error_hpp_ |
9 |
|
|
10 |
|
#include <cxx/platform.hpp> |
11 |
|
|
14 |
|
#endif |
15 |
|
|
16 |
|
#include <api/error.hpp> |
17 |
– |
#include <ios/streams.hpp> |
17 |
|
|
18 |
|
#include <errno.h> |
19 |
|
#include <zlib.h> |
20 |
|
|
21 |
+ |
namespace Zlib |
22 |
+ |
{ |
23 |
+ |
|
24 |
|
class Error : public api::Error |
25 |
|
{ |
26 |
|
int code; |
28 |
|
public: |
29 |
|
Error(gzFile file) : message(::gzerror(file, &code)) |
30 |
|
{ |
31 |
< |
// if (code == Z_ERRNO) |
31 |
> |
if (code == Z_ERRNO) |
32 |
> |
#if defined(API_HAS_POSIX) |
33 |
> |
throw api::Posix::Error(); |
34 |
> |
#endif |
35 |
|
} |
36 |
|
|
37 |
|
virtual int GetNumber() const |
41 |
|
|
42 |
|
virtual cse::String GetMessage() const |
43 |
|
{ |
44 |
< |
return message; |
44 |
> |
return _S<ios::String>() << "Zlib[#" << code << "] " << message; |
45 |
|
} |
46 |
|
}; |
47 |
|
|
61 |
|
return status; |
62 |
|
} |
63 |
|
|
64 |
< |
class GzipWriter : public ios::Writer |
60 |
< |
{ |
61 |
< |
gzFile file; |
62 |
< |
public: |
63 |
< |
GzipWriter(const cse::String &path); |
64 |
< |
virtual ~GzipWriter(); |
65 |
< |
virtual size_t Write(const byte_t *data, size_t length); |
66 |
< |
virtual void Flush(); |
67 |
< |
}; |
64 |
> |
} |
65 |
|
|
66 |
< |
#endif//_GzipWriter_hpp_ |
66 |
> |
#endif//_Zlib_Error_hpp_ |