增加权限信息解析
This commit is contained in:
parent
505ac6436d
commit
8c3a8c5da2
15
ls.go
15
ls.go
@ -8,7 +8,6 @@
|
||||
package command
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"git.zhangdeman.cn/zhangdeman/command/define"
|
||||
@ -64,6 +63,7 @@ func (l *ls) Run() (*define.Result, []define.LsFileInfo) {
|
||||
}
|
||||
resultStr := string(result.Output)
|
||||
fileList := strings.Split(resultStr, "\n")
|
||||
fileListResult := make([]define.LsFileInfo, 0)
|
||||
for _, item := range fileList {
|
||||
if item == "." || item == ".." || len(item) == 0 {
|
||||
// 忽略 . 和 ..
|
||||
@ -74,9 +74,9 @@ func (l *ls) Run() (*define.Result, []define.LsFileInfo) {
|
||||
// 过滤掉对于文件总数的输出
|
||||
continue
|
||||
}
|
||||
l.parseFileInfo(item)
|
||||
fileListResult = append(fileListResult, l.parseFileInfo(item))
|
||||
}
|
||||
return result, nil
|
||||
return result, fileListResult
|
||||
}
|
||||
|
||||
// parseFileInfo 解析文件信息
|
||||
@ -84,11 +84,12 @@ func (l *ls) Run() (*define.Result, []define.LsFileInfo) {
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 17:35 2022/6/27
|
||||
func (l *ls) parseFileInfo(fileLine string) *define.LsFileInfo {
|
||||
func (l *ls) parseFileInfo(fileLine string) define.LsFileInfo {
|
||||
fileInfoArr := strings.Split(fileLine, " ")
|
||||
fmt.Println("文件信息 : ", fileInfoArr)
|
||||
fmt.Println(l.getFilePermission(fileInfoArr[0]))
|
||||
return nil
|
||||
fileInfo := define.LsFileInfo{}
|
||||
// 是否链接 / 是否目录 / 文件权限解析
|
||||
fileInfo.IsLink, fileInfo.IsDir, fileInfo.Permission = l.getFilePermission(fileInfoArr[0])
|
||||
return fileInfo
|
||||
}
|
||||
|
||||
// getFilePermission 解析文件权限信息 , 根据 drwxrwxrwx 这个规范解析
|
||||
|
Loading…
Reference in New Issue
Block a user