From 242db26343bbcee8ae700003fe40131727683582 Mon Sep 17 00:00:00 2001 From: Audrius Butkevicius Date: Sat, 28 May 2016 04:13:34 +0000 Subject: [PATCH] lib/osutil: Fix globbing at root (fixes #3201) GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/3202 --- lib/osutil/glob_windows.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/osutil/glob_windows.go b/lib/osutil/glob_windows.go index afb017c7d..5952f18a5 100644 --- a/lib/osutil/glob_windows.go +++ b/lib/osutil/glob_windows.go @@ -11,6 +11,7 @@ package osutil import ( "os" "path/filepath" + "runtime" "sort" "strings" ) @@ -32,7 +33,9 @@ func Glob(pattern string) (matches []string, err error) { case string(filepath.Separator): // nothing default: - dir = dir[0 : len(dir)-1] // chop off trailing separator + if runtime.GOOS != "windows" || len(dir) < 2 || dir[len(dir)-2] != ':' { + dir = dir[0 : len(dir)-1] // chop off trailing separator, if it's not after the drive letter + } } if !hasMeta(dir) {