MCPcopy Create free account
hub / github.com/OpenAtomFoundation/SmartIDE / IsDirEmpty

Method IsDirEmpty

cli/pkg/common/sshremote.go:207–217  ·  view source on GitHub ↗

文件是否存在

(dirPath string)

Source from the content-addressed store, hash-verified

205
206// 文件是否存在
207func (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// 清空文件夹
220func (instance *SSHRemote) Clear(dirPath string) bool {

Callers 2

checkRemoteDirFunction · 0.80
checkRemoteDirFunction · 0.80

Calls 3

ConvertFilePathMethod · 0.95
ExeSSHCommandMethod · 0.95
CheckErrorFunction · 0.85

Tested by

no test coverage detected