@author: [piexlmax](https://github.com/piexlmax) @function: makeFileContent @description: 创建切片内容 @param: content []byte, fileName string, FileDir string, contentNumber int @return: string, error
(content []byte, fileName string, FileDir string, contentNumber int)
| 58 | //@return: string, error |
| 59 | |
| 60 | func makeFileContent(content []byte, fileName string, FileDir string, contentNumber int) (string, error) { |
| 61 | if strings.Contains(fileName, "..") || strings.Contains(FileDir, "..") { |
| 62 | return "", errors.New("文件名或路径不合法") |
| 63 | } |
| 64 | path := FileDir + fileName + "_" + strconv.Itoa(contentNumber) |
| 65 | f, err := os.Create(path) |
| 66 | if err != nil { |
| 67 | return path, err |
| 68 | } |
| 69 | defer f.Close() |
| 70 | _, err = f.Write(content) |
| 71 | if err != nil { |
| 72 | return path, err |
| 73 | } |
| 74 | |
| 75 | return path, nil |
| 76 | } |
| 77 | |
| 78 | //@author: [piexlmax](https://github.com/piexlmax) |
| 79 | //@function: makeFileContent |
no test coverage detected