1
0
mirror of https://github.com/rclone/rclone.git synced 2025-12-18 17:23:20 +00:00

vendor: add github.com/goftp/server

This commit is contained in:
Nick Craig-Wood
2018-09-14 17:16:54 +01:00
parent a25875170b
commit a14f0d46d7
18 changed files with 2312 additions and 0 deletions

49
vendor/github.com/goftp/server/listformatter.go generated vendored Normal file
View File

@@ -0,0 +1,49 @@
// Copyright 2018 The goftp Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
package server
import (
"bytes"
"fmt"
"strconv"
"strings"
)
type listFormatter []FileInfo
// Short returns a string that lists the collection of files by name only,
// one per line
func (formatter listFormatter) Short() []byte {
var buf bytes.Buffer
for _, file := range formatter {
fmt.Fprintf(&buf, "%s\r\n", file.Name())
}
return buf.Bytes()
}
// Detailed returns a string that lists the collection of files with extra
// detail, one per line
func (formatter listFormatter) Detailed() []byte {
var buf bytes.Buffer
for _, file := range formatter {
fmt.Fprintf(&buf, file.Mode().String())
fmt.Fprintf(&buf, " 1 %s %s ", file.Owner(), file.Group())
fmt.Fprintf(&buf, lpad(strconv.FormatInt(file.Size(), 10), 12))
fmt.Fprintf(&buf, file.ModTime().Format(" Jan _2 15:04 "))
fmt.Fprintf(&buf, "%s\r\n", file.Name())
}
return buf.Bytes()
}
func lpad(input string, length int) (result string) {
if len(input) < length {
result = strings.Repeat(" ", length-len(input)) + input
} else if len(input) == length {
result = input
} else {
result = input[0:length]
}
return
}