Skip to content

Commit

Permalink
Added checking of header inside the ERG file.
Browse files Browse the repository at this point in the history
  • Loading branch information
andnygIPG committed Oct 4, 2023
1 parent 87e711d commit 1a3cc5b
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ function read(ergFile: string, infoFile: string) {
byteOrder: headerBuffer.readUInt8(9),
};

// Check format specified in the ERG header. Error if not ERG
if (!ergHeader.format.startsWith("CM-ERG")) {
throw new Error("Invalid ERG file");
}

// process erg records by reading value for each quantity
let recordBuffer = ergBuffer.slice(16);
let recordIndex = 0;
Expand Down

0 comments on commit 1a3cc5b

Please sign in to comment.