|
|
|
@ -71,8 +71,24 @@ func GetFileModTime(fi fs.FileInfo) (mod string) { |
|
|
|
|
return mod |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func GetFileType() { |
|
|
|
|
//TODO: this function returns the dxrxrx stuff!
|
|
|
|
|
func GetFilePerm(file fs.FileInfo) (perms string) { |
|
|
|
|
perms = "" |
|
|
|
|
mode := file.Mode() |
|
|
|
|
|
|
|
|
|
//Owner
|
|
|
|
|
perms += (string(mode.String()[0])) //d at the start for dir
|
|
|
|
|
for i := 1; i < 4; i++ { |
|
|
|
|
perms += (string(mode.String()[i])) |
|
|
|
|
} |
|
|
|
|
//Group
|
|
|
|
|
for i := 4; i < 7; i++ { |
|
|
|
|
perms += (string(mode.String()[i])) |
|
|
|
|
} |
|
|
|
|
//Other
|
|
|
|
|
for i := 7; i < 10; i++ { |
|
|
|
|
perms += (string(mode.String()[i])) |
|
|
|
|
} |
|
|
|
|
return perms |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func PrintHeaders() { |
|
|
|
@ -96,7 +112,6 @@ func PrintWithoutL(content []fs.DirEntry, isFlagAEnable *bool) { |
|
|
|
|
} else { |
|
|
|
|
fileOutput.Printf(" %s ", item.Name()) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
fmt.Println() |
|
|
|
|
} |
|
|
|
@ -105,14 +120,12 @@ func PrintWithL(content []fs.DirEntry, isFlagAEnable *bool) { |
|
|
|
|
dirOutput := color.New(color.FgMagenta, color.Bold) |
|
|
|
|
fileOutput := color.New(color.FgWhite, color.Bold) |
|
|
|
|
|
|
|
|
|
//print headers
|
|
|
|
|
PrintHeaders() |
|
|
|
|
for _, item := range content { |
|
|
|
|
//we now need extra info from the files
|
|
|
|
|
fi, err := os.Stat(item.Name()) |
|
|
|
|
check(err) |
|
|
|
|
|
|
|
|
|
fType := item.Type().String() |
|
|
|
|
fPerm := GetFilePerm(fi) |
|
|
|
|
fDirSize := "-" |
|
|
|
|
fSize := GetFileSize(fi) |
|
|
|
|
fModTime := GetFileModTime(fi) |
|
|
|
@ -123,9 +136,9 @@ func PrintWithL(content []fs.DirEntry, isFlagAEnable *bool) { |
|
|
|
|
} |
|
|
|
|
//check if item is dir
|
|
|
|
|
if item.IsDir() { |
|
|
|
|
dirOutput.Printf("%s %7s %7s\t%s\n", fType, fDirSize, fModTime, item.Name()) //leave this
|
|
|
|
|
dirOutput.Printf("%s %7s %7s\t%s\n", fPerm, fDirSize, fModTime, item.Name()) |
|
|
|
|
} else { |
|
|
|
|
fmt.Printf("%7s %7s %4s", fType, fSize, fModTime) |
|
|
|
|
fmt.Printf("%7s %7s %4s", fPerm, fSize, fModTime) |
|
|
|
|
fileOutput.Printf("\t%s\n", item.Name()) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|