Equivalent to pread / pwrite in MSVC?

What is the best way to emulate pread / pwrite in MSVC 10?

+3
source share
2 answers

At the C runtime library level, check out fread , fwrite, and fseek .

At the Win32 API level, view ReadFile , WriteFile, and SetFilePointer . MSDN has extensive I / O API file coverage .

Note that both ReadFile and WriteFile accept the OVERLAPPED struct argument, which allows you to specify the file offset. The offset is respected for all files that support byte offsets, even if they are open for synchronous input (I / O).

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

+3
source

It looks like you are simply using the lpOverlapped parameter for ReadFile / WriteFile to pass a pointer to OVERLAPPED with the offset specified in Offset and OffsetHigh .

(: IO, FILE_FLAG_OVERLAPPED.)

+1

Source: https://habr.com/ru/post/1767818/


All Articles