| 240 | } |
| 241 | |
| 242 | private async checkFilePaths( |
| 243 | paths: string[] |
| 244 | ): Promise<Array<{ path: string; isDirectory: boolean; exists: boolean }>> { |
| 245 | try { |
| 246 | const results = await Promise.all( |
| 247 | paths.map(async (filePath) => { |
| 248 | try { |
| 249 | const stats = await fs.stat(filePath) |
| 250 | const result = { |
| 251 | path: filePath, |
| 252 | isDirectory: stats.isDirectory(), |
| 253 | exists: true |
| 254 | } |
| 255 | return result |
| 256 | } catch (error) { |
| 257 | console.log('[System] 主进程:文件不存在或无权访问:', filePath, error) |
| 258 | return { |
| 259 | path: filePath, |
| 260 | isDirectory: false, |
| 261 | exists: false |
| 262 | } |
| 263 | } |
| 264 | }) |
| 265 | ) |
| 266 | return results |
| 267 | } catch (error) { |
| 268 | console.error('[System] 主进程:检查文件路径失败:', error) |
| 269 | return [] |
| 270 | } |
| 271 | } |
| 272 | } |
| 273 | |
| 274 | export default new SystemAPI() |