Skip to content

Instantly share code, notes, and snippets.

@hawkeye64
Created November 18, 2018 19:12
Show Gist options
  • Save hawkeye64/841f35b8f1b9de7d81dd0815bf986e56 to your computer and use it in GitHub Desktop.
Save hawkeye64/841f35b8f1b9de7d81dd0815bf986e56 to your computer and use it in GitHub Desktop.
calling getWindowsDrives
if (process.platform === 'win32') {
getWindowsDrives((error, drives) => {
if (!error) {
this.drives = drives
// work through the drives backwards
for (let index = this.drives.length - 1; index >= 0; --index) {
try {
const stat = fs.statSync(this.drives[index] + path.sep)
let fileInfo = {}
fileInfo.rootDir = this.drives[index]
fileInfo.fileName = path.sep
fileInfo.isDir = stat.isDirectory()
fileInfo.stat = stat
let node = this.createNode(fileInfo)
this.rootDir.unshift(node)
}
catch (error) {
// remove from (bad/phantom) drive list
this.drives.splice(index, 1)
console.error(error)
}
}
}
})
}
else {
// set and get root folder's folders
this.setSelectedFolder(this.drive + path.sep)
this.rootDir.push(...this.getFolders(this.selectedFolder))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment