Created
November 18, 2018 19:12
-
-
Save hawkeye64/841f35b8f1b9de7d81dd0815bf986e56 to your computer and use it in GitHub Desktop.
calling getWindowsDrives
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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