| 51 | } |
| 52 | |
| 53 | uint64_t S3BucketReader::readWithoutHeaderLine(char* buf, uint64_t count) { |
| 54 | char* current = NULL; |
| 55 | char* end = NULL; |
| 56 | char* currentEOL = eolString; |
| 57 | |
| 58 | // check one char at a time |
| 59 | while (*currentEOL != '\0') { |
| 60 | if (current == end) { |
| 61 | uint64_t readCount = this->upstreamReader->read(buf, count); |
| 62 | // we have reach the end of file but found no matching EOL. |
| 63 | if (readCount == 0) { |
| 64 | S3WARN("%s", "Reach end of file before matching line terminator"); |
| 65 | return 0; |
| 66 | } |
| 67 | |
| 68 | current = buf; |
| 69 | end = buf + readCount; |
| 70 | } |
| 71 | |
| 72 | // skip until we met next newline char |
| 73 | for (; current != end; current++) { |
| 74 | if (*current == *currentEOL) { |
| 75 | currentEOL++; |
| 76 | current++; |
| 77 | break; |
| 78 | } else { |
| 79 | currentEOL = eolString; |
| 80 | } |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | // move remained data to front. |
| 85 | uint64_t remain = end - current; |
| 86 | char* p = buf; |
| 87 | while (current != end) { |
| 88 | *p = *current; |
| 89 | p++; |
| 90 | current++; |
| 91 | } |
| 92 | |
| 93 | return remain; |
| 94 | } |
| 95 | |
| 96 | uint64_t S3BucketReader::read(char* buf, uint64_t count) { |
| 97 | S3_CHECK_OR_DIE(this->upstreamReader != NULL, S3RuntimeError, "upstreamReader is NULL"); |