diff options
| author | YDBot <[email protected]> | 2026-06-10 06:27:27 +0000 |
|---|---|---|
| committer | YDBot <[email protected]> | 2026-06-10 06:27:27 +0000 |
| commit | eb8c7d3ee0c13034ecf5d8d35c24cefc40f0bb3f (patch) | |
| tree | a1eba7fec49a258bb24bfa77808233496ac0047f /contrib/go/_std_1.25/src/io/fs/format.go | |
| parent | c4011885693f041c96b035f368aae8a1baac8885 (diff) | |
| parent | 72cfbf8958fa6fa5227e9ad6466abfc635fdeb15 (diff) | |
Diffstat (limited to 'contrib/go/_std_1.25/src/io/fs/format.go')
| -rw-r--r-- | contrib/go/_std_1.25/src/io/fs/format.go | 76 |
1 files changed, 0 insertions, 76 deletions
diff --git a/contrib/go/_std_1.25/src/io/fs/format.go b/contrib/go/_std_1.25/src/io/fs/format.go deleted file mode 100644 index 60b40df1e83..00000000000 --- a/contrib/go/_std_1.25/src/io/fs/format.go +++ /dev/null @@ -1,76 +0,0 @@ -// 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 ( - "time" -) - -// 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 FormatFileInfo(info FileInfo) string { - name := info.Name() - b := make([]byte, 0, 40+len(name)) - b = append(b, info.Mode().String()...) - b = append(b, ' ') - - size := info.Size() - var usize uint64 - if size >= 0 { - usize = uint64(size) - } else { - b = append(b, '-') - usize = uint64(-size) - } - var buf [20]byte - i := len(buf) - 1 - for usize >= 10 { - q := usize / 10 - buf[i] = byte('0' + usize - q*10) - i-- - usize = q - } - buf[i] = byte('0' + usize) - b = append(b, buf[i:]...) - b = append(b, ' ') - - b = append(b, info.ModTime().Format(time.DateTime)...) - b = append(b, ' ') - - b = append(b, name...) - if info.IsDir() { - b = append(b, '/') - } - - return string(b) -} - -// 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 FormatDirEntry(dir DirEntry) string { - name := dir.Name() - b := make([]byte, 0, 5+len(name)) - - // The Type method does not return any permission bits, - // so strip them from the string. - mode := dir.Type().String() - mode = mode[:len(mode)-9] - - b = append(b, mode...) - b = append(b, ' ') - b = append(b, name...) - if dir.IsDir() { - b = append(b, '/') - } - return string(b) -} |
