* 异步获取文件/应用的图标(PNG 格式 Buffer) * @param {string} filePath - 文件路径(可以是 .exe、.lnk、.dll 或任何文件类型) * @returns {Promise } Promise,resolve 为 PNG 格式的图标数据 * @example * // 获取 exe 的图标 * const icon = await IconExtractor.getFileIcon('C:\\Windows\\notepad.exe'); * * // 保存为文件 * const f
(filePath: string)
| 755 | * if (icon) fs.writeFileSync('icon.png', icon); |
| 756 | */ |
| 757 | static getFileIcon(filePath: string): Promise<Buffer> { |
| 758 | if (platform !== 'win32' && platform !== 'darwin') { |
| 759 | throw new Error('getFileIcon is only supported on Windows and macOS') |
| 760 | } |
| 761 | if (typeof filePath !== 'string' || !filePath) { |
| 762 | throw new TypeError('filePath must be a non-empty string') |
| 763 | } |
| 764 | return (addon as NativeAddon).getFileIcon(filePath) |
| 765 | } |
| 766 | } |
| 767 | |
| 768 | /** |
no outgoing calls
no test coverage detected