From e9c594cce082e04a5d4fc3d2d55b2a3fe86be0b2 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 6 Jun 2014 04:50:50 -0400 Subject: [PATCH] fix(win) getVolumes: rm chcp --- lib/server/win.js | 51 ++++++++++++++++++----------------------------- 1 file changed, 19 insertions(+), 32 deletions(-) diff --git a/lib/server/win.js b/lib/server/win.js index c2ab3249..66aca1f4 100644 --- a/lib/server/win.js +++ b/lib/server/win.js @@ -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); + }); + }; })();