MCPcopy
hub / github.com/wavetermdev/waveterm / fileWriteRun

Function fileWriteRun

cmd/wsh/cmd/wshcmd-file.go:241–265  ·  view source on GitHub ↗
(cmd *cobra.Command, args []string)

Source from the content-addressed store, hash-verified

239}
240
241func fileWriteRun(cmd *cobra.Command, args []string) error {
242 path, err := fixRelativePaths(args[0])
243 if err != nil {
244 return err
245 }
246 fileData := wshrpc.FileData{
247 Info: &wshrpc.FileInfo{
248 Path: path}}
249
250 limitReader := io.LimitReader(WrappedStdin, MaxFileSize+1)
251 data, err := io.ReadAll(limitReader)
252 if err != nil {
253 return fmt.Errorf("reading input: %w", err)
254 }
255 if len(data) > MaxFileSize {
256 return fmt.Errorf("input exceeds maximum file size of %d bytes", MaxFileSize)
257 }
258 fileData.Data64 = base64.StdEncoding.EncodeToString(data)
259 err = wshclient.FileWriteCommand(RpcClient, fileData, &wshrpc.RpcOpts{Timeout: fileTimeout})
260 if err != nil {
261 return fmt.Errorf("writing file: %w", err)
262 }
263
264 return nil
265}
266
267func fileAppendRun(cmd *cobra.Command, args []string) error {
268 path, err := fixRelativePaths(args[0])

Callers

nothing calls this directly

Calls 3

FileWriteCommandFunction · 0.92
fixRelativePathsFunction · 0.85
ReadAllMethod · 0.45

Tested by

no test coverage detected