mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 18:55:26 +00:00
fix(win) getVolumes: rm chcp
This commit is contained in:
parent
6ad7b2666d
commit
e9c594cce0
1 changed files with 19 additions and 32 deletions
|
|
@ -16,41 +16,28 @@
|
|||
'# http://cloudcmd.io' + '\n');
|
||||
|
||||
var main = global.cloudcmd.main,
|
||||
Charset ={
|
||||
UNICODE : 65001,
|
||||
WIN32 : 866
|
||||
},
|
||||
|
||||
processExec = main.child_process.exec,
|
||||
Util = main.util;
|
||||
|
||||
exports.getVolumes = function(callback) {
|
||||
var chcp = 'chcp ' + Charset.UNICODE,
|
||||
getVolumes = 'wmic logicaldisk get name';
|
||||
|
||||
processExec(chcp + ' && ' + getVolumes, Util.exec.with(processOuput, callback));
|
||||
};
|
||||
|
||||
function processOuput(callback, error, stdout, stderr) {
|
||||
var volumes = [],
|
||||
removeStr = [
|
||||
'\r', '\n',
|
||||
'Name',
|
||||
'Active code page: 65001 '
|
||||
];
|
||||
|
||||
if (!error)
|
||||
error = stderr;
|
||||
|
||||
processExec('chcp ' + Charset.WIN32);
|
||||
|
||||
if(!error) {
|
||||
volumes = Util.rmStr(stdout, removeStr)
|
||||
.split(' ');
|
||||
processExec('wmic logicaldisk get name', function(error, stdout, stderr) {
|
||||
var volumes = [],
|
||||
removeStr = [
|
||||
'\r', '\n',
|
||||
'Name', ' ',
|
||||
];
|
||||
|
||||
volumes.pop();
|
||||
}
|
||||
|
||||
Util.exec(callback, error || volumes);
|
||||
}
|
||||
if (!error)
|
||||
error = stderr;
|
||||
|
||||
if(!error) {
|
||||
volumes = Util.rmStr(stdout, removeStr)
|
||||
.split(':');
|
||||
|
||||
volumes.pop();
|
||||
}
|
||||
|
||||
Util.exec(callback, error || volumes);
|
||||
});
|
||||
};
|
||||
})();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue