瀏覽代碼

lib/osutil: Fix globbing at root (fixes #3201)

GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/3202
Audrius Butkevicius 9 年之前
父節點
當前提交
242db26343
共有 1 個文件被更改,包括 4 次插入1 次删除
  1. 4 1
      lib/osutil/glob_windows.go

+ 4 - 1
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) {