16 #if FOXXLL_HAVE_WINCALL_FILE 32 void wincall_file::serve(
void* buffer, offset_type offset, size_type
bytes,
35 std::unique_lock<std::mutex> fd_lock(fd_mutex_);
37 if (bytes > 32 * 1024 * 1024) {
38 TLX_LOG1 <<
"Using a block size larger than 32 MiB" 39 <<
" may not work with the " << io_type() <<
" filetype";
42 HANDLE handle = file_des_;
43 LARGE_INTEGER desired_pos;
44 desired_pos.QuadPart = offset;
45 if (!SetFilePointerEx(handle, desired_pos,
nullptr, FILE_BEGIN))
47 FOXXLL_THROW_WIN_LASTERROR(
49 "SetFilePointerEx in wincall_request::serve()" <<
50 " offset=" << offset <<
52 " buffer=" << buffer <<
59 file_stats::scoped_read_write_timer read_write_timer(
64 DWORD NumberOfBytesRead = 0;
66 if (!ReadFile(handle, buffer, (DWORD)bytes, &NumberOfBytesRead,
nullptr))
68 FOXXLL_THROW_WIN_LASTERROR(
72 " offset=" << offset <<
73 " buffer=" << buffer <<
76 " NumberOfBytesRead= " << NumberOfBytesRead
79 else if (NumberOfBytesRead != bytes) {
80 FOXXLL_THROW_WIN_LASTERROR(io_error,
" partial read: missing " << (bytes - NumberOfBytesRead) <<
" out of " << bytes <<
" bytes");
85 DWORD NumberOfBytesWritten = 0;
87 if (!WriteFile(handle, buffer, (DWORD)bytes, &NumberOfBytesWritten,
nullptr))
89 FOXXLL_THROW_WIN_LASTERROR(
93 " offset=" << offset <<
94 " buffer=" << buffer <<
97 " NumberOfBytesWritten= " << NumberOfBytesWritten
100 else if (NumberOfBytesWritten != bytes) {
101 FOXXLL_THROW_WIN_LASTERROR(io_error,
" partial write: missing " << (bytes - NumberOfBytesWritten) <<
" out of " << bytes <<
" bytes");
107 const char* wincall_file::io_type()
const 114 #endif // #if FOXXLL_HAVE_WINCALL_FILE static uint_pair max()
return an uint_pair instance containing the largest value possible
static const size_t bytes
number of bytes in uint_pair