mirror of
https://github.com/rclone/rclone.git
synced 2024-12-24 07:59:07 +01:00
e92cb9e8f8
Add --network-mode option to activate mounting as network drive without having to set volume prefix. Add support for automatic drive letter assignment (not specific to network drive mounting). Allow full network share unc path in --volname, which will also implicitely activate network drive mounting. Allow full network share unc path as mountpoint, which will also implicitely activate network drive mounting, and the specified path will be used as volume prefix and the remote will be mounted on an automatically assigned drive letter instead.
23 lines
585 B
Go
23 lines
585 B
Go
//+build windows
|
|
|
|
package file
|
|
|
|
import (
|
|
"os"
|
|
)
|
|
|
|
// FindUnusedDriveLetter searches mounted drive list on the system
|
|
// (starting from Z: and ending at D:) for unused drive letter.
|
|
// Returns the letter found (like 'Z') or zero value.
|
|
func FindUnusedDriveLetter() (driveLetter uint8) {
|
|
// Do not use A: and B:, because they are reserved for floppy drive.
|
|
// Do not use C:, because it is normally used for main drive.
|
|
for l := uint8('Z'); l >= uint8('D'); l-- {
|
|
_, err := os.Stat(string(l) + ":" + string(os.PathSeparator))
|
|
if os.IsNotExist(err) {
|
|
return l
|
|
}
|
|
}
|
|
return 0
|
|
}
|