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

Function RenameAppFile

pkg/waveappstore/waveappstore.go:378–407  ·  view source on GitHub ↗
(appId string, fromFileName string, toFileName string)

Source from the content-addressed store, hash-verified

376}
377
378func RenameAppFile(appId string, fromFileName string, toFileName string) error {
379 if err := ValidateAppId(appId); err != nil {
380 return fmt.Errorf("invalid appId: %w", err)
381 }
382
383 appDir, err := GetAppDir(appId)
384 if err != nil {
385 return err
386 }
387
388 fromPath, err := validateAndResolveFilePath(appDir, fromFileName)
389 if err != nil {
390 return fmt.Errorf("invalid source path: %w", err)
391 }
392
393 toPath, err := validateAndResolveFilePath(appDir, toFileName)
394 if err != nil {
395 return fmt.Errorf("invalid destination path: %w", err)
396 }
397
398 if err := os.MkdirAll(filepath.Dir(toPath), 0755); err != nil {
399 return fmt.Errorf("failed to create destination directory: %w", err)
400 }
401
402 if err := os.Rename(fromPath, toPath); err != nil {
403 return fmt.Errorf("failed to rename file: %w", err)
404 }
405
406 return nil
407}
408
409func FormatGoFile(appId string, fileName string) error {
410 if err := ValidateAppId(appId); err != nil {

Callers 1

RenameAppFileCommandMethod · 0.92

Calls 3

ValidateAppIdFunction · 0.85
GetAppDirFunction · 0.85

Tested by

no test coverage detected