Line data Source code
1 : //
2 : // Author: Vladimir Migashko <migashko@gmail.com>, (C) 2012
3 : //
4 : // Copyright: See COPYING file that comes with this distribution
5 : //
6 :
7 : #ifndef VSET_VSET_BUFFER_PERSISTENT_FILE_AD_READ_FILE_HPP
8 : #define VSET_VSET_BUFFER_PERSISTENT_FILE_AD_READ_FILE_HPP
9 :
10 : #include <vset/buffer/tags.hpp>
11 : #include <vset/buffer/persistent/tags.hpp>
12 :
13 : #include <fcntl.h>
14 :
15 : namespace vset { namespace buffer { namespace persistent{ namespace file{
16 :
17 12 : struct ad_read_file
18 : {
19 : template<typename T>
20 16 : void operator()( T& t, char* data, size_t size, size_t offset )
21 : {
22 16 : if ( -1 == ::pread( t.get_aspect().template get<_descriptor_>() , data, size, static_cast<off_t>(offset) ) )
23 : {
24 0 : throw std::runtime_error(strerror(errno));
25 : }
26 16 : }
27 : };
28 :
29 : }}}}
30 :
31 : #endif
|