1//go:build windows
2
3package fsext
4
5import (
6 "cmp"
7 "os"
8 "path/filepath"
9)
10
11// WindowsWorkingDirDrive returns the drive letter of the current working
12// directory, e.g. "C:".
13// Falls back to the system drive if the current working directory cannot be
14// determined.
15func WindowsWorkingDirDrive() string {
16 if cwd, err := os.Getwd(); err == nil {
17 return filepath.VolumeName(cwd)
18 }
19 return WindowsSystemDrive()
20}
21
22// WindowsSystemDrive returns the drive letter of the system drive, e.g. "C:".
23func WindowsSystemDrive() string {
24 systemRoot := cmp.Or(os.Getenv("SYSTEMROOT"), os.Getenv("WINDIR"))
25 return filepath.VolumeName(systemRoot)
26}