fix(win) getVolumes: rm chcp

This commit is contained in:
coderaiser 2014-06-06 04:50:50 -04:00
parent 6ad7b2666d
commit e9c594cce0

View file

@ -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);
});
};
})();