albfernandez / javadbf

Java library for reading and writing Xbase (dBase/DBF) files.
GNU Lesser General Public License v3.0
224 stars 98 forks source link

Why not write reserved fields in DBFField.write() ? #104

Closed jmor7690 closed 2 years ago

jmor7690 commented 2 years ago

Currently, DBFField writes zero values for the reserved fields (line 283 and below). Why not write the approppriate fields instead?

https://github.com/albfernandez/javadbf/blob/aef1fe983b578df426349ee701ca9abd96f64e27/src/main/java/com/linuxense/javadbf/DBFField.java#L283

Proposed change:

// data type
out.writeByte(this.type.getCode()); /* 11 */
out.writeInt(DBFUtils.littleEndian(this.reserv1)); //0x00); /* 12-15 */
out.writeByte(this.length); /* 16 */
out.writeByte(this.decimalCount); /* 17 */
out.writeShort(DBFUtils.littleEndian(this.reserv2)); //(short) 0x00); /* 18-19 */
out.writeByte(this.workAreaId); //(byte) 0x00); /* 20 */
out.writeShort(DBFUtils.littleEndian(this.reserv3)); //(short) 0x00); /* 21-22 */
out.writeByte(this.setFieldsFlag); //(byte) 0x00); /* 23 */
out.write(this.reserv4); //new byte[7]); /* 24-30 */
out.writeByte(this.indexFieldFlag); //(byte) 0x00); /* 31 */