(appId string, fromFileName string, toFileName string)
| 376 | } |
| 377 | |
| 378 | func 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 | |
| 409 | func FormatGoFile(appId string, fileName string) error { |
| 410 | if err := ValidateAppId(appId); err != nil { |
no test coverage detected