From efc7a5ebc9e10983571c080017100a8b39eee1d0 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 15 Nov 2017 21:39:40 -0500 Subject: more --- types.go | 65 ---------------------------------------------------------------- 1 file changed, 65 deletions(-) delete mode 100644 types.go (limited to 'types.go') diff --git a/types.go b/types.go deleted file mode 100644 index 1ce0741..0000000 --- a/types.go +++ /dev/null @@ -1,65 +0,0 @@ -package libfastimport - -import ( - "fmt" - "strings" - "time" -) - -type UserTime struct { - Name string - Email string - Time time.Time -} - -func (ut UserTime) String() string { - if ut.Name == "" { - return fmt.Sprintf("<%s> %d %s", - ut.Name, - ut.Email, - ut.Time.Unix(), - ut.Time.Format("-0700")) - } else { - return fmt.Sprintf("%s <%s> %d %s", - ut.Name, - ut.Email, - ut.Time.Unix(), - ut.Time.Format("-0700")) - } -} - -type Mode uint32 // 18 bits - -var ( - ModeFil = Mode(0100644) - ModeExe = Mode(0100755) - ModeSym = Mode(0120000) - ModeGit = Mode(0160000) - ModeDir = Mode(0040000) -) - -func (m Mode) String() string { - return fmt.Sprintf("%06o", m) -} - -func PathEscape(path string) string { - if strings.HasPrefix(path, "\"") || strings.ContainsRune(path, '\n') { - return "\"" + strings.Replace(strings.Replace(strings.Replace(path, "\\", "\\\\", -1), "\"", "\\\"", -1), "\n", "\\n", -1) + "\"" - } else { - return path - } -} - -func PathUnescape(epath string) string { - if strings.HasPrefix(epath, "\"") { - return strings.Replace(strings.Replace(strings.Replace(epath[1:len(epath)-1], "\\n", "\n", -1), "\\\"", "\"", -1), "\\\\", "\\", -1) - } else { - return epath - } -} - -type Path string - -func (p Path) String() string { - return PathEscape(string(p)) -} -- cgit v1.2.3