// Copyright 2023 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package fs

import (
	
)

// FormatFileInfo returns a formatted version of info for human readability.
// Implementations of [FileInfo] can call this from a String method.
// The output for a file named "hello.go", 100 bytes, mode 0o644, created
// January 1, 1970 at noon is
//
//	-rw-r--r-- 100 1970-01-01 12:00:00 hello.go
func ( FileInfo) string {
	 := .Name()
	 := make([]byte, 0, 40+len())
	 = append(, .Mode().String()...)
	 = append(, ' ')

	 := .Size()
	var  uint64
	if  >= 0 {
		 = uint64()
	} else {
		 = append(, '-')
		 = uint64(-)
	}
	var  [20]byte
	 := len() - 1
	for  >= 10 {
		 :=  / 10
		[] = byte('0' +  - *10)
		--
		 = 
	}
	[] = byte('0' + )
	 = append(, [:]...)
	 = append(, ' ')

	 = append(, .ModTime().Format(time.DateTime)...)
	 = append(, ' ')

	 = append(, ...)
	if .IsDir() {
		 = append(, '/')
	}

	return string()
}

// FormatDirEntry returns a formatted version of dir for human readability.
// Implementations of [DirEntry] can call this from a String method.
// The outputs for a directory named subdir and a file named hello.go are:
//
//	d subdir/
//	- hello.go
func ( DirEntry) string {
	 := .Name()
	 := make([]byte, 0, 5+len())

	// The Type method does not return any permission bits,
	// so strip them from the string.
	 := .Type().String()
	 = [:len()-9]

	 = append(, ...)
	 = append(, ' ')
	 = append(, ...)
	if .IsDir() {
		 = append(, '/')
	}
	return string()
}