Skip to content

Commit

Permalink
Merge pull request #152 from ehotinger/ehotinger/fs
Browse files Browse the repository at this point in the history
Updates the error message in GetFileSystemType
  • Loading branch information
jterry75 authored Jul 2, 2019
2 parents 7cdfd71 + 28396ed commit 881e3d4
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pkg/fs/fs_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,17 @@ import (
"golang.org/x/sys/windows"
)

var (
// ErrInvalidPath is returned when the location of a file path doesn't begin with a driver letter.
ErrInvalidPath = errors.New("the path provided to GetFileSystemType must start with a drive letter")
)

// GetFileSystemType obtains the type of a file system through GetVolumeInformation.
// https://msdn.microsoft.com/en-us/library/windows/desktop/aa364993(v=vs.85).aspx
func GetFileSystemType(path string) (fsType string, hr error) {
drive := filepath.VolumeName(path)
if len(drive) != 2 {
return "", errors.New("getFileSystemType path must start with a drive letter")
return "", ErrInvalidPath
}

var (
Expand Down

0 comments on commit 881e3d4

Please sign in to comment.