Comparing version 1.10.0 to 1.11.0
@@ -252,3 +252,4 @@ "use strict"; | ||
// The code below assumes the block size is at offset 4 in the .dbt for dBase IV files, and defaults to 512 if | ||
// all zeros. For dBase III files, the block size is always 512 bytes. | ||
// all zeros. For dBase III files, the block size is always 512 bytes. For VFP9 the block size is at offset 6. | ||
// VFP9 memos can have a block size of 1, a special case where each block is sized to fit its value. | ||
let memoBlockSize = 0; | ||
@@ -260,3 +261,3 @@ let memoFileSize = 0; | ||
if (dbf._version === 0x30) { | ||
// FoxPro9 | ||
// VFP9 | ||
await utils_1.read(memoFd, buffer, 0, 2, 6); | ||
@@ -375,4 +376,16 @@ memoBlockSize = buffer.readUInt16BE(0) || 512; | ||
while (true) { | ||
// Read the next block-sized chunk from the memo file. | ||
await utils_1.read(memoFd, memoBuf, 0, memoBlockSize, blockIndex * memoBlockSize); | ||
if (memoBlockSize > 1) { | ||
// Read the next block-sized chunk from the memo file. | ||
await utils_1.read(memoFd, memoBuf, 0, memoBlockSize, blockIndex * memoBlockSize); | ||
} | ||
else { | ||
// VFP9 with block size 1. This means the block size is variable to fit each value. | ||
// Read the memo length from the block header. | ||
memoBuf = memoBuf.length >= 4 ? memoBuf : Buffer.alloc(4); | ||
await utils_1.read(memoFd, memoBuf, 0, 4, blockIndex + 4); | ||
len = memoBuf.readInt32BE(0); | ||
// read the entire memo value (without the header). | ||
memoBuf = Buffer.alloc(len); | ||
await utils_1.read(memoFd, memoBuf, 0, len, blockIndex + 8); | ||
} | ||
// Handle first/next block of dBase III memo data. | ||
@@ -430,2 +443,7 @@ if (dbf._version === 0x83) { | ||
let skip = 0; | ||
if (memoBlockSize == 1) { | ||
// For VFP9 with block size 1, the entire memo value is in memoBuf. | ||
value = iconv.decode(memoBuf, encoding); | ||
break; | ||
} | ||
if (!mergedBuffer.length) { | ||
@@ -432,0 +450,0 @@ const memoType = memoBuf.readInt32BE(0); |
@@ -12,1 +12,3 @@ For information about the dBase III (.dbf) file format, see: | ||
- https://github.com/infused/dbf/tree/master/spec/fixtures | ||
For details about Visual FoxPro 9 memo fields with block size 1, see [this article](./vfp9-bs1.pdf) |
{ | ||
"name": "dbffile", | ||
"version": "1.10.0", | ||
"version": "1.11.0", | ||
"description": "Read and write .dbf (dBase III & Visual FoxPro) files in Node.js", | ||
@@ -18,3 +18,3 @@ "main": "dist/index.js", | ||
"type": "git", | ||
"url": "https://github.com/yortus/DBFFile.git" | ||
"url": "git+https://github.com/yortus/DBFFile.git" | ||
}, | ||
@@ -21,0 +21,0 @@ "keywords": [ |
@@ -11,2 +11,3 @@ # DBFFile | ||
- `F` (float) | ||
- `Y` (currency) | ||
- `I` (integer) | ||
@@ -13,0 +14,0 @@ - `L` (logical) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
206481
18
977
202