Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Equivalent to pread/pwrite in MSVC?

What calls best emulate pread/pwrite in MSVC 10?

like image 686
Matt Joiner Avatar asked Oct 04 '10 04:10

Matt Joiner


1 Answers

At the C runtime library level, look at fread, fwrite and fseek.

At the Win32 API level, have a look at ReadFile, WriteFile, and SetFilePointer. MSDN has extensive coverage of file I/O API's.

Note that both ReadFile and WriteFile take an OVERLAPPED struct argument, which lets you specify a file offset. The offset is respected for all files that support byte offsets, even when opened for synchronous (i.e. non 'overlapped') I/O.

Depending on the problem you are trying to solve, file mapping may be a better design choice.

like image 62
Oren Trutner Avatar answered Sep 29 '22 02:09

Oren Trutner