restic/cmd/restic/format.go

41 lines
704 B
Go
Raw Normal View History

2016-09-17 10:36:05 +00:00
package main
import (
"fmt"
"os"
2017-07-24 15:42:25 +00:00
"github.com/restic/restic/internal/restic"
2016-09-17 10:36:05 +00:00
)
2018-06-09 16:56:40 +00:00
func formatNode(path string, n *restic.Node, long bool) string {
if !long {
2018-06-09 16:56:40 +00:00
return path
}
2017-12-03 16:34:37 +00:00
var mode os.FileMode
var target string
switch n.Type {
case "file":
2017-12-03 16:34:37 +00:00
mode = 0
case "dir":
2017-12-03 16:34:37 +00:00
mode = os.ModeDir
case "symlink":
2017-12-03 16:34:37 +00:00
mode = os.ModeSymlink
target = fmt.Sprintf(" -> %v", n.LinkTarget)
case "dev":
mode = os.ModeDevice
case "chardev":
mode = os.ModeDevice | os.ModeCharDevice
case "fifo":
mode = os.ModeNamedPipe
case "socket":
mode = os.ModeSocket
}
2017-12-03 16:34:37 +00:00
return fmt.Sprintf("%s %5d %5d %6d %s %s%s",
mode|n.Mode, n.UID, n.GID, n.Size,
2018-11-02 19:36:15 +00:00
n.ModTime.Local().Format(TimeFormat), path,
2017-12-03 16:34:37 +00:00
target)
}