1 |
// Truck Computer Dooom! |
2 |
// |
3 |
// Douglas Thrift |
4 |
// |
5 |
// $Id$ |
6 |
|
7 |
#ifndef _posix_hpp_ |
8 |
#define _posix_hpp_ |
9 |
|
10 |
#include <cerrno> |
11 |
#include <cstring> |
12 |
#include <exception> |
13 |
|
14 |
namespace Posix |
15 |
{ |
16 |
|
17 |
inline int CheckError(int status); |
18 |
|
19 |
class Error : public std::exception |
20 |
{ |
21 |
int code; |
22 |
char message[1024]; |
23 |
|
24 |
public: |
25 |
Error(); |
26 |
virtual ~Error() throw() {} |
27 |
|
28 |
virtual int GetCode() const { return code; } |
29 |
virtual const char *what() const throw() { return message; } |
30 |
}; |
31 |
|
32 |
inline int CheckError(int status) |
33 |
{ |
34 |
if (status == -1) |
35 |
throw Error(); |
36 |
|
37 |
return status; |
38 |
} |
39 |
|
40 |
} |
41 |
|
42 |
#endif//_posix_hpp_ |