MCPcopy Index your code
hub / github.com/micro-editor/micro / Truncate

Method Truncate

internal/buffer/save.go:124–133  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

122}
123
124func (wf wrappedFile) Truncate() error {
125 if wf.withSudo {
126 // we don't need to stop the screen here, since it is still stopped
127 // by openFile()
128 // truncate might not be available on every platfom, so use dd instead
129 cmd := exec.Command(config.GlobalSettings["sucmd"].(string), "dd", "count=0", "of="+wf.name)
130 return cmd.Run()
131 }
132 return wf.writeCloser.(*os.File).Truncate(0)
133}
134
135func (wf wrappedFile) Write(b *SharedBuffer) (int, error) {
136 file := bufio.NewWriter(transform.NewWriter(wf.writeCloser, b.encoding.NewEncoder()))

Callers 2

WriteMethod · 0.95
SafeWriteFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected