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

Comparing Common/posix.cpp (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  
11   #define _XOPEN_SOURCE 600
12  
13 + #include <fcntl.h>
14 +
15   #include "posix.hpp"
16  
17   namespace Posix
# Line 20 | Line 22 | Error::Error() : code(errno)
22          CheckError(::strerror_r(code, message, sizeof (message)));
23   }
24  
25 + int Open(const std::string &path, int flags, ::mode_t mode)
26 + {
27 +        return SysCall(::open, path.c_str(), flags, mode);
28 + }
29 +
30 + size_t Read(int fd, void *buffer, size_t bytes)
31 + {
32 +        return SysCall(::read, fd, buffer, bytes);
33 + }
34 +
35 + size_t ReadMost(int fd, void *buffer, size_t bytes)
36 + {
37 +        size_t rest(bytes);
38 +        uint8_t *data = reinterpret_cast<uint8_t *>(buffer);
39 +
40 +        while (rest != 0)
41 +        {
42 +                size_t read(Read(fd, data, rest));
43 +
44 +                if (read == 0)
45 +                        return bytes - rest;
46 +
47 +                data += read;
48 +                rest -= read;
49 +        }
50 +
51 +        return bytes;
52 + }
53 +
54   }

Comparing Common/posix.cpp (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