refactor: filetype 识别

This commit is contained in:
手瓜一十雪
2024-11-22 15:33:52 +08:00
parent 6fa7a973ba
commit 515c1af676
3 changed files with 17 additions and 10 deletions

View File

@@ -19,14 +19,6 @@ type Uri2LocalRes = {
path: string
}
export function isGIF(path: string) {
const buffer = Buffer.alloc(4);
const fd = fs.openSync(path, 'r');
fs.readSync(fd, buffer, 0, 4, 0);
fs.closeSync(fd);
return buffer.toString() === 'GIF8';
}
// 定义一个异步函数来检查文件是否存在
export function checkFileExist(path: string, timeout: number = 3000): Promise<void> {
return new Promise((resolve, reject) => {