MCPcopy Create free account
hub / github.com/bcndev/bytecoin / read_some

Method read_some

src/platform/Files.cpp:118–131  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

116#endif
117}
118size_t FileStream::read_some(void *data, size_t size) {
119 size = std::min(size, MAX_CHUNK); // Some oses cannot read more than 2 gb at once
120#ifdef _WIN32
121 DWORD si = 0;
122 if (!ReadFile(handle, data, static_cast<DWORD>(size), &si, nullptr))
123 throw common::StreamError("Error reading file, GetLastError()=" + common::to_string(GetLastError()));
124 return si;
125#else
126 ssize_t si = ::read(fd, data, size);
127 if (si == -1)
128 throw common::StreamError("Error reading file, errno=" + common::to_string(errno));
129 return (size_t)si;
130#endif
131}
132
133void FileStream::fsync() {
134#ifdef _WIN32

Callers 1

sync_http_requestFunction · 0.45

Calls 4

minFunction · 0.85
StreamErrorClass · 0.85
to_stringFunction · 0.50
readFunction · 0.50

Tested by

no test coverage detected