ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/truck/Common/posix.hpp
(Generate patch)

Comparing Common/posix.hpp (file contents):
Revision 10 by douglas, 2007-05-07T16:54:45-07:00 vs.
Revision 14 by douglas, 2007-05-14T18:24:34-07:00

# Line 10 | Line 10
10   #include <cerrno>
11   #include <cstring>
12   #include <exception>
13 + #include <string>
14  
15   namespace Posix
16   {
# Line 26 | Line 27 | public:
27          virtual ~Error() throw() {}
28  
29          virtual int GetCode() const { return code; }
30 +        virtual std::string GetMessage() const { return message; }
31          virtual const char *what() const throw() { return message; }
32   };
33  
# Line 37 | Line 39 | inline int CheckError(int status)
39          return status;
40   }
41  
42 + #define _SysCall(call) \
43 +        int status; \
44 +        \
45 +        while ((status = call) == -1) \
46 +                if (errno != EINTR) \
47 +                        throw Error(); \
48 +                else \
49 +                        continue; \
50 +        \
51 +        return status
52 +
53 + template <typename Function_, typename Arg0_, typename Arg1_>
54 + int SysCall(Function_ function, Arg0_ arg0, Arg1_ arg1)
55 + {
56 +        _SysCall(function(arg0, arg1));
57 + }
58 +
59 + template <typename Function_, typename Arg0_, typename Arg1_, typename Arg2_>
60 + int SysCall(Function_ function, Arg0_ arg0, Arg1_ arg1, Arg2_ arg2)
61 + {
62 +        _SysCall(function(arg0, arg1, arg2));
63 + }
64 +
65 + #undef _SysCall
66 +
67 + int Open(const std::string &path, int flags, ::mode_t mode);
68 +
69 + inline int Open(const std::string &path, int flags)
70 + {
71 +        return Open(path, flags, 0);
72 + }
73 +
74 + size_t Read(int fd, void *buffer, size_t bytes);
75 + size_t ReadMost(int fd, void *buffer, size_t bytes);
76 +
77   }
78  
79   #endif//_posix_hpp_

Comparing Common/posix.hpp (property svn:keywords):
Revision 10 by douglas, 2007-05-07T16:54:45-07:00 vs.
Revision 14 by douglas, 2007-05-14T18:24:34-07:00

# Line 1 | Line 1
1 < Common/common.hpp
1 > Id

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines