MCPcopy Create free account
hub / github.com/anchordotdev/cli / AppendToFile

Method AppendToFile

truststore/fs.go:94–111  ·  view source on GitHub ↗
(name string, p []byte)

Source from the content-addressed store, hash-verified

92}
93
94func (r *rootFS) AppendToFile(name string, p []byte) error {
95 f, err := os.OpenFile(filepath.Join(r.rootPath, name), os.O_APPEND|os.O_WRONLY, 0644)
96 if err != nil {
97 if !os.IsNotExist(err) {
98 return err
99 }
100
101 if f, err = os.Create(filepath.Join(r.rootPath, name)); err != nil {
102 return err
103 }
104 }
105 defer f.Close()
106
107 if _, err := f.Write(p); err != nil {
108 return err
109 }
110 return f.Close()
111}
112
113func (r *rootFS) Rename(oldpath, newpath string) error {
114 src, dst := filepath.Join(r.rootPath, oldpath), filepath.Join(r.rootPath, newpath)

Callers

nothing calls this directly

Calls 1

CloseMethod · 0.45

Tested by

no test coverage detected