void flush() { stream->write(buffer, buffer_pos); buffer_pos = 0; if(flush_event != nullptr) { flush_event->run(); } }
void FoxPro::saveFields(WriteStream &dbf) const { for (size_t i = 0; i < _fields.size(); i++) { const Field &field = _fields[i]; int l = strlen(field.name.c_str()); dbf.write(field.name.c_str(), MIN(10, l)); dbf.writeByte(0x00); while ((10 - l++) > 0) dbf.writeByte(0x00); dbf.writeByte((byte) ((char) field.type)); dbf.writeUint32LE(field.offset); dbf.writeByte(field.size); dbf.writeByte(field.decimals); dbf.writeByte(field.flags); dbf.writeUint32LE(field.autoIncNext); dbf.writeByte (field.autoIncStep); dbf.writeUint32LE(0x00000000); // Reserved dbf.writeUint32LE(0x00000000); // Reserved } dbf.writeByte(0x0D); // Field end marker }
void ArrayObject::save(const chowstring & filename) { FSFile fp(convert_path(filename).c_str(), "w"); if (!fp.is_open()) return; WriteStream stream; stream.write(CT_ARRAY_MAGIC, sizeof(CT_ARRAY_MAGIC)); stream.write_int16(ARRAY_MAJOR_VERSION); stream.write_int16(ARRAY_MINOR_VERSION); stream.write_int32(data.x_size); stream.write_int32(data.y_size); stream.write_int32(data.z_size); int flags = 0; if (data.is_numeric) flags |= NUMERIC_FLAG; if (data.offset != 0) flags |= BASE1_FLAG; stream.write_int32(flags); for (int i = 0; i < data.x_size * data.y_size * data.z_size; i++) { if (data.is_numeric) { stream.write_int32(int(data.array[i])); } else { stream.write_int32(data.strings[i].size()); stream.write_string(data.strings[i]); } } stream.save(fp); fp.close(); }
void FoxPro::saveMemos(WriteStream &fpt) const { fpt.writeUint32BE(_memos.size() + 1); // Next free block fpt.writeUint16BE(0x0000); // Reserved fpt.writeUint16BE(_memoBlockSize); // Reserved for (int i = 0; i < 126; i++) fpt.writeUint32BE(0x00000000); for (size_t i = 0; i < _memos.size(); i++) fpt.write(_memos[i], _memoBlockSize); }
void FoxPro::saveRecords(WriteStream &dbf) const { // Write the records for (size_t i = 0; i < _records.size(); i++) { const Record &record = _records[i]; dbf.writeByte(record.deleted ? '*' : ' '); for (size_t j = 0; j < _fields.size(); j++) dbf.write(record.fields[j], _fields[j].size); } dbf.writeByte(0x1A); // Records end marker }