* 读取目录内容 * @param {string} directory 目录路径 * @returns {Promise } 文件名列表
(directory)
| 41 | * @returns {Promise<string|Buffer>} 文件内容 |
| 42 | */ |
| 43 | async readFile(filePath, encoding = 'utf-8') { |
| 44 | try { |
| 45 | return await fsp.readFile(filePath, encoding === null ? undefined : encoding); |
| 46 | } catch (err) { |
| 47 | logger.error(`读取文件 ${filePath} 时出错:`, err); |
| 48 | throw err; |
| 49 | } |
| 50 | }, |
| 51 | |
| 52 | /** |
| 53 | * 写入文件 |
nothing calls this directly
no outgoing calls
no test coverage detected