文件是否存在
(dirPath string)
| 205 | |
| 206 | // 文件是否存在 |
| 207 | func (instance *SSHRemote) IsDirEmpty(dirPath string) bool { |
| 208 | |
| 209 | dirPath = instance.ConvertFilePath(dirPath) |
| 210 | |
| 211 | command := fmt.Sprintf(`[ "$(sudo ls -A %v)" ] && echo "0" || echo "111111"`, dirPath) |
| 212 | //e.g. ls: cannot access '/home/localadmin/project/test001'111111\n: No such file or directory |
| 213 | outContent, err := instance.ExeSSHCommand(command) |
| 214 | CheckError(err) |
| 215 | |
| 216 | return strings.Contains(outContent, "111111") || strings.Contains(outContent, "No such file or directory") |
| 217 | } |
| 218 | |
| 219 | // 清空文件夹 |
| 220 | func (instance *SSHRemote) Clear(dirPath string) bool { |
no test coverage detected