windows: allow accessing other drives than the default one (list drives when the file browser reaches the filesystem's root)
This commit is contained in:
parent
37ee994dab
commit
275ea3c14b
2 changed files with 32 additions and 0 deletions
|
|
@ -1,5 +1,10 @@
|
|||
# Changelog
|
||||
|
||||
## 1.16.4
|
||||
|
||||
- misc
|
||||
- windows: allow accessing other drives than the default one (list drives when the file browser reaches the filesystem's root)
|
||||
|
||||
## 1.16.3
|
||||
|
||||
- bug fixes
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ var path = require('path'),
|
|||
osc = require('./osc'),
|
||||
{ipc} = require('./server'),
|
||||
{deepCopy, resolveHomeDir} = require('./utils'),
|
||||
child_process = require('child_process'),
|
||||
fragmentManager
|
||||
|
||||
var widgetHashTable = {},
|
||||
|
|
@ -497,6 +498,32 @@ module.exports = {
|
|||
|
||||
if (root && !path.normalize(p).includes(path.normalize(root))) p = root
|
||||
|
||||
|
||||
if (process.platform === 'win32' && !root) {
|
||||
// Drive list hack on windows
|
||||
if (data.path.length === 2 && data.path[1] === '..' && (data.path[0].match(/^[A-Z]:\\$/) || data.path[0] === '\\')) {
|
||||
|
||||
child_process.exec('wmic logicaldisk get name', (error, stdout) => {
|
||||
|
||||
if (error) {
|
||||
|
||||
ipc.send('notify', {class: 'error', message: 'Failed to list available drives.'}, clientId)
|
||||
|
||||
} else {
|
||||
|
||||
ipc.send('listDir', {
|
||||
path: '\\',
|
||||
files: stdout.split('\r\r\n')
|
||||
.filter(value => /[A-Za-z]:/.test(value))
|
||||
.map(value => {return {name: value.trim(), folder: true}})
|
||||
}, clientId)
|
||||
|
||||
}
|
||||
})
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
fs.readdir(p, (err, files)=>{
|
||||
if (err) {
|
||||
ipc.send('notify', {class: 'error', message: err.message}, clientId)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue