mirror of
https://github.com/develop202/migu_video.git
synced 2025-12-17 23:34:45 +08:00
回放,h5失效
This commit is contained in:
32
utils/fileUtil.js
Normal file
32
utils/fileUtil.js
Normal file
@@ -0,0 +1,32 @@
|
||||
import fs from "fs"
|
||||
function createFile(filePath) {
|
||||
if (!fs.existsSync(filePath)) {
|
||||
writeFile(filePath, "")
|
||||
}
|
||||
}
|
||||
|
||||
function writeFile(filePath, content) {
|
||||
fs.writeFile(filePath, content, error => {
|
||||
if (error) {
|
||||
throw new Error(`${filePath}:写入${content}失败`)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function appendFile(filePath, content) {
|
||||
fs.appendFile(filePath, content, error => {
|
||||
if (error) {
|
||||
throw new Error(`${filePath}:追加${content}失败`)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function appendFileSync(filePath, content) {
|
||||
fs.appendFileSync(filePath, content, error => {
|
||||
if (error) {
|
||||
throw new Error(`${filePath}:同步追加${content}失败`)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export { createFile, writeFile, appendFile, appendFileSync }
|
||||
Reference in New Issue
Block a user