* 读取文件头部内容
(filePath: string, size: number = HEAD_SIZE)
| 14 | * 读取文件头部内容 |
| 15 | */ |
| 16 | function readFileHead(filePath: string, size: number = HEAD_SIZE): string { |
| 17 | const fd = fs.openSync(filePath, 'r') |
| 18 | const buffer = Buffer.alloc(size) |
| 19 | const bytesRead = fs.readSync(fd, buffer, 0, size, 0) |
| 20 | fs.closeSync(fd) |
| 21 | return buffer.slice(0, bytesRead).toString('utf-8') |
| 22 | } |
| 23 | |
| 24 | /** |
| 25 | * 获取文件扩展名(小写) |
no outgoing calls
no test coverage detected