MCPcopy
hub / github.com/flipped-aurora/gin-vue-admin / makeFileContent

Function makeFileContent

server/utils/breakpoint_continue.go:60–76  ·  view source on GitHub ↗

@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)

Source from the content-addressed store, hash-verified

58//@return: string, error
59
60func 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

Callers 1

BreakPointContinueFunction · 0.85

Calls 4

NewMethod · 0.65
CloseMethod · 0.65
CreateMethod · 0.45
WriteMethod · 0.45

Tested by

no test coverage detected