MCPcopy
hub / github.com/danielmiessler/Fabric / CreateOutputFile

Function CreateOutputFile

internal/cli/output.go:22–42  ·  view source on GitHub ↗
(message string, fileName string)

Source from the content-addressed store, hash-verified

20}
21
22func CreateOutputFile(message string, fileName string) (err error) {
23 if _, err = os.Stat(fileName); err == nil {
24 err = fmt.Errorf(i18n.T("file_already_exists_not_overwriting"), fileName)
25 return
26 }
27 var file *os.File
28 if file, err = os.Create(fileName); err != nil {
29 err = fmt.Errorf(i18n.T("error_creating_file"), err)
30 return
31 }
32 defer file.Close()
33 if !strings.HasSuffix(message, "\n") {
34 message += "\n"
35 }
36 if _, err = file.WriteString(message); err != nil {
37 err = fmt.Errorf(i18n.T("error_writing_to_file"), err)
38 } else {
39 debuglog.Log("\n\n[Output also written to %s]\n", fileName)
40 }
41 return
42}
43
44// CreateAudioOutputFile creates a binary file for audio data
45func CreateAudioOutputFile(audioData []byte, fileName string) (err error) {

Callers 5

handleChatProcessingFunction · 0.85
WriteOutputFunction · 0.85
WriteOutputMethod · 0.85
TestCreateOutputFileFunction · 0.85

Calls 2

TFunction · 0.92
CloseMethod · 0.45