diff --git a/README.md b/README.md
index 6bfdecb..bb2b585 100644
--- a/README.md
+++ b/README.md
@@ -58,13 +58,14 @@ await archive.init();
The ReadArchive constructor optionally accepts an [ReadArchiveOptions](src/Options/ReadArchiveOptions.js) object with
the following properties:
-| Name | Type | Description |
-|----------------------------------|---------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
-| `centralDirectoryBufferSize` | number | Buffer size used when reading central directory contents.
Larger buffer sizes may improve performance, but also increase RAM usage. |
-| `createEntryIndex` | boolean | Whether an index of all central directory entries should be created the first time they are read.
Massively increases performance when using `findEntry` multiple times. |
-| `entryOptions` | [EntryOptions](src/Options/EntryOptions.js) | Options passed to each created Entry object. |
-| `ignoreMultiDiskErrors` | boolean | Simply ignore information about multiple disks instead of throwing an error when encountering a multi disk archive |
-| `allowTruncatedCentralDirectory` | boolean | Do not throw an error if the central directory does not contain the expected number of entries |
+| Name | Type | Description |
+|------------------------------------------|---------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
+| `centralDirectoryBufferSize` | number | Buffer size used when reading central directory contents.
Larger buffer sizes may improve performance, but also increase RAM usage. |
+| `createEntryIndex` | boolean | Whether an index of all central directory entries should be created the first time they are read.
Massively increases performance when using `findEntry` multiple times. |
+| `entryOptions` | [EntryOptions](src/Options/EntryOptions.js) | Options passed to each created Entry object. |
+| `ignoreMultiDiskErrors` | boolean | Simply ignore information about multiple disks instead of throwing an error when encountering a multi disk archive |
+| `allowTruncatedCentralDirectory` | boolean | Do not throw an error if the central directory does not contain the expected number of entries |
+| `allowAdditionalCentralDirectoryEntries` | boolean | Continue reading central directory entries even after the expected number of entries was reached |
[EntryOptions](src/Options/EntryOptions.js) can have the following properties:
diff --git a/src/Archive/Entry/EntryIterator.js b/src/Archive/Entry/EntryIterator.js
index 8f907e0..094db59 100644
--- a/src/Archive/Entry/EntryIterator.js
+++ b/src/Archive/Entry/EntryIterator.js
@@ -54,7 +54,9 @@ export default class EntryIterator {
*/
async next() {
if (this.currentEntry >= this.entryCount) {
- return null;
+ if (!this.archive.options.allowAdditionalCentralDirectoryEntries || this.io.offset >= BigInt(this.startOffset) + this.size) {
+ return null;
+ }
}
if (this.io.offset >= BigInt(this.startOffset) + this.size) {
if (!this.archive.options.allowTruncatedCentralDirectory) {
diff --git a/src/Options/ReadArchiveOptions.js b/src/Options/ReadArchiveOptions.js
index 74f4433..b5b0654 100644
--- a/src/Options/ReadArchiveOptions.js
+++ b/src/Options/ReadArchiveOptions.js
@@ -8,6 +8,7 @@ import Constants from '../Constants.js';
* @property {EntryOptions|EntryOptionsObject} [entryOptions]
* @property {boolean} [ignoreMultiDiskErrors]
* @property {boolean} [allowTruncatedCentralDirectory]
+ * @property {boolean} [allowAdditionalCentralDirectoryEntries]
*/
@@ -17,5 +18,6 @@ export default class ReadArchiveOptions extends Options {
/** @type {EntryOptions|EntryOptionsObject} */ entryOptions = {};
/** @type {boolean} */ ignoreMultiDiskErrors = false;
/** @type {boolean} */ allowTruncatedCentralDirectory = false;
+ /** @type {boolean} */ allowAdditionalCentralDirectoryEntries = false;
}