MCPcopy Create free account
hub / github.com/CalcProgrammer1/OpenRGB / read

Method read

dependencies/httplib/httplib.h:4641–4685  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4639}
4640
4641inline ssize_t SocketStream::read(char *ptr, size_t size) {
4642#ifdef _WIN32
4643 size =
4644 (std::min)(size, static_cast<size_t>((std::numeric_limits<int>::max)()));
4645#else
4646 size = (std::min)(size,
4647 static_cast<size_t>((std::numeric_limits<ssize_t>::max)()));
4648#endif
4649
4650 if (read_buff_off_ < read_buff_content_size_) {
4651 auto remaining_size = read_buff_content_size_ - read_buff_off_;
4652 if (size <= remaining_size) {
4653 memcpy(ptr, read_buff_.data() + read_buff_off_, size);
4654 read_buff_off_ += size;
4655 return static_cast<ssize_t>(size);
4656 } else {
4657 memcpy(ptr, read_buff_.data() + read_buff_off_, remaining_size);
4658 read_buff_off_ += remaining_size;
4659 return static_cast<ssize_t>(remaining_size);
4660 }
4661 }
4662
4663 if (!is_readable()) { return -1; }
4664
4665 read_buff_off_ = 0;
4666 read_buff_content_size_ = 0;
4667
4668 if (size < read_buff_size_) {
4669 auto n = read_socket(sock_, read_buff_.data(), read_buff_size_,
4670 CPPHTTPLIB_RECV_FLAGS);
4671 if (n <= 0) {
4672 return n;
4673 } else if (n <= static_cast<ssize_t>(size)) {
4674 memcpy(ptr, read_buff_.data(), static_cast<size_t>(n));
4675 return n;
4676 } else {
4677 memcpy(ptr, read_buff_.data(), size);
4678 read_buff_off_ = size;
4679 read_buff_content_size_ = static_cast<size_t>(n);
4680 return static_cast<ssize_t>(size);
4681 }
4682 } else {
4683 return read_socket(sock_, ptr, size, CPPHTTPLIB_RECV_FLAGS);
4684 }
4685}
4686
4687inline ssize_t SocketStream::write(const char *ptr, size_t size) {
4688 if (!is_writable()) { return -1; }

Callers 12

LoadProfileToListMethod · 0.45
UpdateProfileListMethod · 0.45
__init__Method · 0.45
add_fileMethod · 0.45
check_file_for_issueMethod · 0.45
check_file_for_issueMethod · 0.45
read_fileFunction · 0.45
getlineMethod · 0.45
read_content_with_lengthFunction · 0.45
skip_content_with_lengthFunction · 0.45

Calls 2

read_socketFunction · 0.85
dataMethod · 0.80

Tested by 1