/* fetchkey(): This massages the key into a form that's easier to handle. When it returns, the key will be stored in keybuf if keysize <= 4; otherwise, it will be in memory. */ static void fetchkey(unsigned char *keybuf, glui32 key, glui32 keysize, glui32 options) { int ix; if (options & serop_KeyIndirect) { if (keysize <= 4) { for (ix=0; ix<keysize; ix++) keybuf[ix] = Mem1(key+ix); } } else { switch (keysize) { case 4: Write4(keybuf, key); break; case 2: Write2(keybuf, key); break; case 1: Write1(keybuf, key); break; default: fatal_error("Direct search key must hold one, two, or four bytes."); } } }
void FastOS_FileInterface::WriteBufInternal(const void *buffer, size_t length) { ssize_t writeResult = Write2(buffer, length); if (length - writeResult != 0) { std::string errorString = writeResult != -1 ? std::string("short write") : FastOS_FileInterface::getLastErrorString(); std::ostringstream os; os << "Fatal: Writing " << length << " bytes to '" << GetFileName() << "' failed (wrote " << writeResult << "): " << errorString; throw std::runtime_error(os.str()); } }
bool FastOS_FileInterface::CheckedWrite(const void *buffer, size_t len) { ssize_t writeResult = Write2(buffer, len); if (writeResult < 0) { std::string errorString = FastOS_FileInterface::getLastErrorString(); fprintf(stderr, "Writing %lu bytes to '%s' failed: %s\n", static_cast<unsigned long>(len), GetFileName(), errorString.c_str()); return false; } if (writeResult != (ssize_t)len) { fprintf(stderr, "Short write, tried to write %lu bytes to '%s', only wrote %lu bytes\n", static_cast<unsigned long>(len), GetFileName(), static_cast<unsigned long>(writeResult)); return false; } return true; }
// public void Write(string value) [instance] :591 void BinaryWriter::Write24(uString* value) { uArray* bytes = ::g::Uno::Runtime::Implementation::TextEncodingImpl::EncodeUtf8(value); Write7BitEncodedInt(uPtr(bytes)->Length()); Write2(bytes); }
static int write_short(dest_t *dest, glui16 val) { unsigned char buf[2]; Write2(buf, val); return write_buffer(dest, buf, 2); }