feat: 添加对本地文件的操作接口

This commit is contained in:
TsMask
2025-04-25 15:38:07 +08:00
parent 81e1112166
commit be5fb5eb94
6 changed files with 308 additions and 6 deletions

View File

@@ -16,7 +16,7 @@ type FileListRow struct {
LinkCount int64 `json:"linkCount"` // 硬链接数目
Owner string `json:"owner"` // 所属用户
Group string `json:"group"` // 所属组
Size string `json:"size"` // 文件的大小
Size int64 `json:"size"` // 文件的大小
ModifiedTime int64 `json:"modifiedTime"` // 最后修改时间,单位为秒
FileName string `json:"fileName"` // 文件的名称
}
@@ -34,10 +34,10 @@ func FileList(sshClient *ConnSSH, path, search string) ([]FileListRow, error) {
if search != "" {
searchStr = search + searchStr
}
// cd /var/log && find. -maxdepth 1 -name'mme*' -exec ls -lthd --time-style=+%s {} +
cmdStr := fmt.Sprintf("cd %s && find . -maxdepth 1 -name '%s' -exec ls -lthd --time-style=+%%s {} +", path, searchStr)
// cd /var/log && ls -lthd --time-style=+%s mme*
// cmdStr := fmt.Sprintf("cd %s && ls -lthd --time-style=+%%s %s", path, searchStr)
// cd /var/log && find. -maxdepth 1 -name'mme*' -exec ls -ltd --time-style=+%s {} +
cmdStr := fmt.Sprintf("cd %s && find . -maxdepth 1 -name '%s' -exec ls -ltd --time-style=+%%s {} +", path, searchStr)
// cd /var/log && ls -ltd --time-style=+%s mme*
// cmdStr := fmt.Sprintf("cd %s && ls -ltd --time-style=+%%s %s", path, searchStr)
// 是否远程客户端读取
if sshClient == nil {
@@ -94,7 +94,7 @@ func FileList(sshClient *ConnSSH, path, search string) ([]FileListRow, error) {
LinkCount: parse.Number(fields[1]),
Owner: fields[2],
Group: fields[3],
Size: fields[4],
Size: parse.Number(fields[4]),
ModifiedTime: parse.Number(fields[5]),
FileName: fileName,
})