std::string readCStringFromWin32Binary(FAFile* file, size_t ptr, size_t offset) { if (ptr) return readCString(file, ptr - offset); return ""; }
/** * scratch must be empty when passed in. It will be used if there is a NUL byte in the * output string. In that case the returned StringData will point into scratch, otherwise * it will point directly into the input buffer. */ StringData readCStringWithNuls(BufReader* reader, std::string* scratch) { const StringData initial = readCString(reader); if (reader->peek<unsigned char>() != 0xFF) return initial; // Don't alloc or copy for simple case with no NUL bytes. scratch->append(initial.rawData(), initial.size()); while (reader->peek<unsigned char>() == 0xFF) { // Each time we enter this loop it means we hit a NUL byte encoded as "\x00\xFF". *scratch += '\0'; reader->skip(1); const StringData nextPart = readCString(reader); scratch->append(nextPart.rawData(), nextPart.size()); } return *scratch; }
void CCByteBuffer::read(string& dest) { readCString(dest); }
void ByteBuffer::read(std::string& dest) { readCString(dest); }