From 76491af8b67b58f8a910ffc2c6d49e16b272a7eb Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 14 Dec 2012 08:10:20 -0500 Subject: [PATCH] minor changes --- lib/server/main.js | 2 +- lib/server/win.js | 172 ++++++++++++++++++++++----------------------- 2 files changed, 87 insertions(+), 87 deletions(-) diff --git a/lib/server/main.js b/lib/server/main.js index f3ae13fb..67c2cd61 100644 --- a/lib/server/main.js +++ b/lib/server/main.js @@ -1,6 +1,6 @@ (function(){ "strict mode"; - + /* Global var accessible from any loaded module */ global.cloudcmd = {}; diff --git a/lib/server/win.js b/lib/server/win.js index b86e42d4..9a7b58e3 100644 --- a/lib/server/win.js +++ b/lib/server/win.js @@ -1,86 +1,86 @@ -/* - * Library contain windows specific functions - * like getting information about volumes - */ - -(function(){ - "use strict"; - - if(!global.cloudcmd) - return console.log( - '# win.js' + '\n' + - '# -----------' + '\n' + - '# Module is part of Cloud Commander,' + '\n' + - '# used for work with windows specific' + '\n' + - '# functions. Woud be work on win32 only.' + '\n' + - '# http://coderaiser.github.com/cloudcmd' + '\n'); - - var main = global.cloudcmd.main, - Charset ={ - UNICODE : 65001, - WIN32 : 866 - }, - - exec = main.child_process.exec, - Util = main.util; - - - exports.getVolumes = function(pCallBack){ - var SRVDIR = '.\\', - BATDIR = SRVDIR + 'win\\', - SCENARIO = BATDIR + 'getvolumes.txt', - lCHCP = 'chcp ' + Charset.UNICODE, - lDiskPart = 'diskpart -s "' + SCENARIO + '"'; - - exec(lCHCP + ' && ' + lDiskPart, retProcessOuput(pCallBack)); - }; - - - function retProcessOuput(pCallBack){ - return function(pError, pStdout, pStderr){ - /** - * get position of current name of volume - * @param pNumber = number of volume - */ - var getPosition = function(pNumber){ - var lRet, - lstrPattern = 'Том '; - - lRet = pStdout.indexOf(lstrPattern + pNumber); - - return lRet; - }; - - /** - * get name of volume - * @param pPosition - current char position - */ - var getVolumeName = function (pPosition){ - var lRet, - lCharPosition = 10; - - lRet = pStdout[pPosition + lCharPosition]; - - return lRet; - }; - - var lVolumes = []; - - exec('chcp ' + Charset.WIN32); - - if(!pError){ - var i = 0, - lNum = getPosition(i); - - do{ - lVolumes[i] = getVolumeName(lNum); - lNum = getPosition(++i); - }while(lNum > 0); - } - else - Util.log(pError); - - Util.exec(pCallBack, lVolumes); - }; - } -})(); +/* + * Library contain windows specific functions + * like getting information about volumes + */ + +(function(){ + "use strict"; + + if(!global.cloudcmd) + return console.log( + '# win.js' + '\n' + + '# -----------' + '\n' + + '# Module is part of Cloud Commander,' + '\n' + + '# used for work with windows specific' + '\n' + + '# functions. Woud be work on win32 only.' + '\n' + + '# http://coderaiser.github.com/cloudcmd' + '\n'); + + var main = global.cloudcmd.main, + Charset ={ + UNICODE : 65001, + WIN32 : 866 + }, + + exec = main.child_process.exec, + Util = main.util; + + + exports.getVolumes = function(pCallBack){ + var SRVDIR = main.SRVDIR, + BATDIR = SRVDIR + 'win\\', + SCENARIO = BATDIR + 'getvolumes.txt', + lCHCP = 'chcp ' + Charset.UNICODE, + lDiskPart = 'diskpart -s "' + SCENARIO + '"'; + + exec(lCHCP + ' && ' + lDiskPart, retProcessOuput(pCallBack)); + }; + + + function retProcessOuput(pCallBack){ + return function(pError, pStdout, pStderr){ + /** + * get position of current name of volume + * @param pNumber = number of volume + */ + var getPosition = function(pNumber){ + var lRet, + lstrPattern = 'Том '; + + lRet = pStdout.indexOf(lstrPattern + pNumber); + + return lRet; + }; + + /** + * get name of volume + * @param pPosition - current char position + */ + var getVolumeName = function (pPosition){ + var lRet, + lCharPosition = 10; + + lRet = pStdout[pPosition + lCharPosition]; + + return lRet; + }; + + var lVolumes = []; + + exec('chcp ' + Charset.WIN32); + + if(!pError){ + var i = 0, + lNum = getPosition(i); + + do{ + lVolumes[i] = getVolumeName(lNum); + lNum = getPosition(++i); + }while(lNum > 0); + } + else + Util.log(pError); + + Util.exec(pCallBack, lVolumes); + }; + } +})();