()
| 16 | let cacheDisks: string[] = []; |
| 17 | |
| 18 | export function getWindowsDisks() { |
| 19 | if (os.platform() !== "win32") return []; |
| 20 | if (cacheDisks.length > 0) return cacheDisks; |
| 21 | const res: string[] = []; |
| 22 | // A - Z |
| 23 | for (let i = 65; i <= 90; i++) { |
| 24 | const letter = String.fromCharCode(i); |
| 25 | try { |
| 26 | if (fs.existsSync(`${letter}:\\`)) res.push(letter); |
| 27 | } catch (error) { |
| 28 | // ignore error |
| 29 | } |
| 30 | } |
| 31 | cacheDisks = res; |
| 32 | return res; |
| 33 | } |