创建文件夹
This commit is contained in:
@@ -8,8 +8,11 @@ import (
|
||||
"omc/handle/model"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/aceld/zinx/zlog"
|
||||
)
|
||||
|
||||
//BJ/HX/RJ/OMC/FM/告警文件生成时间
|
||||
@@ -42,6 +45,15 @@ func FileName(meta *FileNameMeta) string {
|
||||
}
|
||||
|
||||
func CreateFile(filePath string, data []model.OmcAlarm) error {
|
||||
// 获取文件所在的目录路径
|
||||
dirPath := filepath.Dir(filePath)
|
||||
|
||||
// 确保文件夹路径存在
|
||||
err := os.MkdirAll(dirPath, os.ModePerm)
|
||||
if err != nil {
|
||||
zlog.Ins().ErrorF("创建文件夹失败 CreateFile %v", err)
|
||||
}
|
||||
|
||||
// 创建或打开文件
|
||||
file, err := os.Create(filePath)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user