2016-09-17 10:36:05 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2017-03-08 19:29:31 +00:00
|
|
|
"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 {
|
2017-03-08 19:29:31 +00:00
|
|
|
if !long {
|
2018-06-09 16:56:40 +00:00
|
|
|
return path
|
2017-03-08 19:29:31 +00:00
|
|
|
}
|
|
|
|
|
2017-12-03 16:34:37 +00:00
|
|
|
var mode os.FileMode
|
|
|
|
var target string
|
|
|
|
|
2017-03-08 19:29:31 +00:00
|
|
|
switch n.Type {
|
|
|
|
case "file":
|
2017-12-03 16:34:37 +00:00
|
|
|
mode = 0
|
2017-03-08 19:29:31 +00:00
|
|
|
case "dir":
|
2017-12-03 16:34:37 +00:00
|
|
|
mode = os.ModeDir
|
2017-03-08 19:29:31 +00:00
|
|
|
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-03-08 19:29:31 +00:00
|
|
|
}
|
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)
|
2017-03-08 19:29:31 +00:00
|
|
|
}
|