MCPcopy
hub / github.com/cortexlabs/cortex / WriteFile

Function WriteFile

pkg/lib/files/files.go:160–171  ·  view source on GitHub ↗
(data []byte, path string)

Source from the content-addressed store, hash-verified

158}
159
160func WriteFile(data []byte, path string) error {
161 cleanPath, err := EscapeTilde(path)
162 if err != nil {
163 return err
164 }
165
166 if err := ioutil.WriteFile(cleanPath, data, 0664); err != nil {
167 return errors.Wrap(err, errors.Message(ErrorCreateFile(path)))
168 }
169
170 return nil
171}
172
173func IsAbsOrTildePrefixed(path string) bool {
174 return strings.HasPrefix(path, "/") || strings.HasPrefix(path, "~/")

Callers 6

WriteJSONFunction · 0.92
writeCLIConfigFunction · 0.92
clientIDFunction · 0.92
cluster.goFile · 0.92
TestListDirRecursiveFunction · 0.85

Calls 4

WrapFunction · 0.92
MessageFunction · 0.92
EscapeTildeFunction · 0.85
ErrorCreateFileFunction · 0.85

Tested by 1

TestListDirRecursiveFunction · 0.68