MCPcopy Create free account
hub / github.com/Shazbot/WH3-Mod-Manager / ensurePackFileReadyForWrite

Function ensurePackFileReadyForWrite

src/packFileSerializer.ts:2316–2333  ·  view source on GitHub ↗
(packFile: NewPackedFile)

Source from the content-addressed store, hash-verified

2314 return Buffer.concat(buffers);
2315};
2316const ensurePackFileReadyForWrite = (packFile: NewPackedFile): NewPackedFile => {
2317 if (packFile.buffer) {
2318 if (packFile.file_size == null) {
2319 packFile.file_size = packFile.buffer.length;
2320 }
2321 return packFile;
2322 }
2323 if (packFile.file_size != null) {
2324 return packFile;
2325 }
2326 if (!packFile.schemaFields || !packFile.tableSchema) {
2327 throw new Error(`Pack file "${packFile.name}" is missing file_size and cannot be serialized`);
2328 }
2329 const buffer = serializePackFileDataToBuffer(packFile);
2330 packFile.buffer = buffer;
2331 packFile.file_size = buffer.length;
2332 return packFile;
2333};
2334const ensurePackFilesReadyForWrite = (packFiles: NewPackedFile[]): NewPackedFile[] => {
2335 for (const packFile of packFiles) {
2336 ensurePackFileReadyForWrite(packFile);

Callers 1

Calls 1

Tested by

no test coverage detected