(filePath: string, bytes = XZ_MAGIC.length)
| 118 | } |
| 119 | |
| 120 | const readFileHeader = async (filePath: string, bytes = XZ_MAGIC.length): Promise<Buffer> => { |
| 121 | const fileHandle = await open(filePath, 'r') |
| 122 | |
| 123 | try { |
| 124 | const header = Buffer.alloc(bytes) |
| 125 | const { bytesRead } = await fileHandle.read(header, 0, bytes, 0) |
| 126 | |
| 127 | return header.subarray(0, bytesRead) |
| 128 | } finally { |
| 129 | await fileHandle.close() |
| 130 | } |
| 131 | } |
| 132 | |
| 133 | export const detectCompressionFormat = async ( |
| 134 | filePath: string, |
no test coverage detected