package sftp

import (
	
	
	
	
	
	

	sshfx 
)

func lsFormatID( uint32) string {
	return strconv.FormatUint(uint64(), 10)
}

type osIDLookup struct{}

func (osIDLookup) (*Request) (ListerAt, error) {
	return nil, errors.New("unimplemented stub")
}

func (osIDLookup) ( string) string {
	,  := user.LookupId()
	if  != nil {
		return 
	}

	return .Username
}

func (osIDLookup) ( string) string {
	,  := user.LookupGroupId()
	if  != nil {
		return 
	}

	return .Name
}

// runLs formats the FileInfo as per `ls -l` style, which is in the 'longname' field of a SSH_FXP_NAME entry.
// This is a fairly simple implementation, just enough to look close to openssh in simple cases.
func runLs( NameLookupFileLister,  os.FileInfo) string {
	// example from openssh sftp server:
	// crw-rw-rw-    1 root     wheel           0 Jul 31 20:52 ttyvd
	// format:
	// {directory / char device / etc}{rwxrwxrwx}  {number of links} owner group size month day [time (this year) | year (otherwise)] name

	 := sshfx.FileMode(fromFileMode(.Mode())).String()

	var  uint64 = 1
	,  := "0", "0"

	switch sys := .Sys().(type) {
	case *sshfx.Attributes:
		 = lsFormatID(.UID)
		 = lsFormatID(.GID)
	case *FileStat:
		 = lsFormatID(.UID)
		 = lsFormatID(.GID)
	default:
		if ,  := .(FileInfoUidGid);  {
			 = lsFormatID(.Uid())
			 = lsFormatID(.Gid())

			break
		}

		, ,  = lsLinksUIDGID()
	}

	if  != nil {
		,  = .LookupUserName(), .LookupGroupName()
	}

	 := .ModTime()
	 := .Format("Jan 2")

	var  string
	if .Before(time.Now().AddDate(0, -6, 0)) {
		 = .Format("2006")
	} else {
		 = .Format("15:04")
	}

	return fmt.Sprintf("%s %4d %-8s %-8s %8d %s %5s %s", , , , , .Size(), , , .Name())
}