...
1 package fs
2
3 import (
4 "errors"
5 "path/filepath"
6
7 "golang.org/x/sys/windows"
8
9 "github.com/Microsoft/go-winio/internal/stringbuffer"
10 )
11
12 var (
13
14 ErrInvalidPath = errors.New("the path provided to GetFileSystemType must start with a drive letter")
15 )
16
17
18
19
20 func GetFileSystemType(path string) (fsType string, err error) {
21 drive := filepath.VolumeName(path)
22 if len(drive) != 2 {
23 return "", ErrInvalidPath
24 }
25
26 buf := stringbuffer.NewWString()
27 defer buf.Free()
28
29 drive += `\`
30 err = windows.GetVolumeInformation(windows.StringToUTF16Ptr(drive), nil, 0, nil, nil, nil, buf.Pointer(), buf.Cap())
31 return buf.String(), err
32 }
33
View as plain text