MCPcopy Create free account
hub / github.com/CodingGay/BlackDex / pread

Function pread

Bcore/src/main/cpp/android-base/file.cpp:159–172  ·  view source on GitHub ↗

Windows implementation of pread. Note that this DOES move the file descriptors read position, but it does so atomically.

Source from the content-addressed store, hash-verified

157// Windows implementation of pread. Note that this DOES move the file descriptors read position,
158// but it does so atomically.
159static ssize_t pread(int fd, void* data, size_t byte_count, off64_t offset) {
160 DWORD bytes_read;
161 OVERLAPPED overlapped;
162 memset(&overlapped, 0, sizeof(OVERLAPPED));
163 overlapped.Offset = static_cast<DWORD>(offset);
164 overlapped.OffsetHigh = static_cast<DWORD>(offset >> 32);
165 if (!ReadFile(reinterpret_cast<HANDLE>(_get_osfhandle(fd)), data, static_cast<DWORD>(byte_count),
166 &bytes_read, &overlapped)) {
167 // In case someone tries to read errno (since this is masquerading as a POSIX call)
168 errno = EIO;
169 return -1;
170 }
171 return static_cast<ssize_t>(bytes_read);
172}
173#endif
174
175bool ReadFullyAtOffset(int fd, void* data, size_t byte_count, off64_t offset) {

Callers 2

pread64Function · 0.85
ReadFullyAtOffsetFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected