(p *api.PikPak, currentPath string, args []string)
| 601 | } |
| 602 | |
| 603 | func changeDirectory(p *api.PikPak, currentPath string, args []string) (string, error) { |
| 604 | target := "/" |
| 605 | if len(args) > 0 { |
| 606 | target = args[0] |
| 607 | } |
| 608 | |
| 609 | targetPath := resolveShellPath(currentPath, target) |
| 610 | if targetPath == "/" { |
| 611 | return targetPath, nil |
| 612 | } |
| 613 | |
| 614 | if _, err := p.GetPathFolderId(targetPath); err != nil { |
| 615 | return "", fmt.Errorf("cd: %s: no such directory", targetPath) |
| 616 | } |
| 617 | |
| 618 | return targetPath, nil |
| 619 | } |
| 620 | |
| 621 | func resolveShellPath(currentPath string, target string) string { |
| 622 | switch strings.TrimSpace(target) { |
no test coverage detected