增加文件权限信息的解析
This commit is contained in:
parent
5617bb7761
commit
505ac6436d
30
ls.go
30
ls.go
@ -87,5 +87,35 @@ func (l *ls) Run() (*define.Result, []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
|
||||
}
|
||||
|
||||
// getFilePermission 解析文件权限信息 , 根据 drwxrwxrwx 这个规范解析
|
||||
//
|
||||
// Author : go_developer@163.com<白茶清欢>
|
||||
//
|
||||
// Date : 17:37 2022/6/27
|
||||
func (l *ls) getFilePermission(permissionLayout string) (bool, bool, *define.FullPermission) {
|
||||
permissionArr := strings.Split(permissionLayout, "")
|
||||
if len(permissionArr) < 10 {
|
||||
return false, false, nil
|
||||
}
|
||||
return permissionArr[0] == "l", permissionArr[0] == "d", &define.FullPermission{
|
||||
User: define.FilePermission{
|
||||
Read: permissionArr[1] == "r",
|
||||
Write: permissionArr[2] == "w",
|
||||
Exec: permissionArr[3] == "x",
|
||||
},
|
||||
Group: define.FilePermission{
|
||||
Read: permissionArr[4] == "r",
|
||||
Write: permissionArr[5] == "w",
|
||||
Exec: permissionArr[6] == "x",
|
||||
},
|
||||
Other: define.FilePermission{
|
||||
Read: permissionArr[7] == "r",
|
||||
Write: permissionArr[8] == "w",
|
||||
Exec: permissionArr[9] == "x",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user