2016-11-13 01:04:55 +01:00
|
|
|
// +build !cgo,!plan9 windows android
|
|
|
|
|
|
|
|
package sftp
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
2017-09-30 16:27:27 +02:00
|
|
|
"time"
|
|
|
|
"fmt"
|
2016-11-13 01:04:55 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
func runLs(dirname string, dirent os.FileInfo) string {
|
2017-09-30 16:27:27 +02:00
|
|
|
typeword := runLsTypeWord(dirent)
|
|
|
|
numLinks := 1
|
|
|
|
if dirent.IsDir() {
|
|
|
|
numLinks = 0
|
|
|
|
}
|
|
|
|
username := "root"
|
|
|
|
groupname := "root"
|
|
|
|
mtime := dirent.ModTime()
|
|
|
|
monthStr := mtime.Month().String()[0:3]
|
|
|
|
day := mtime.Day()
|
|
|
|
year := mtime.Year()
|
|
|
|
now := time.Now()
|
|
|
|
isOld := mtime.Before(now.Add(-time.Hour * 24 * 365 / 2))
|
|
|
|
|
|
|
|
yearOrTime := fmt.Sprintf("%02d:%02d", mtime.Hour(), mtime.Minute())
|
|
|
|
if isOld {
|
|
|
|
yearOrTime = fmt.Sprintf("%d", year)
|
|
|
|
}
|
|
|
|
|
|
|
|
return fmt.Sprintf("%s %4d %-8s %-8s %8d %s %2d %5s %s", typeword, numLinks, username, groupname, dirent.Size(), monthStr, day, yearOrTime, dirent.Name())
|
2016-11-13 01:04:55 +01:00
|
|
|
}
|