From e7868a8b0208ed069e030fa31c60d8e1d56ef209 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 14 Dec 2012 05:10:15 -0500 Subject: [PATCH] added functions in win.js for parsing diskpart output --- ChangeLog | 3 ++ lib/server/appcache.js | 2 +- lib/server/auth.js | 2 +- lib/server/rest.js | 2 +- lib/server/update.js | 4 +-- lib/server/win.js | 76 ++++++++++++++++++++++++++++++++++++++++-- 6 files changed, 82 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 30d4ff9b..aa4d3e4d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,6 +8,9 @@ * Added functions DOM.getCurrentFileContent(pCallBack [, pCurrentFile]) and Util.setTimeout(pFunction [, pCallBack, pTime]) +* Added functions in win.js for parsing diskpart output. + + 2012.12.12, Version 0.1.8 * Added ability to shutdown Cloud Commander diff --git a/lib/server/appcache.js b/lib/server/appcache.js index e30028a2..00360dfc 100644 --- a/lib/server/appcache.js +++ b/lib/server/appcache.js @@ -10,7 +10,7 @@ '# used for work with Aplication Cache.' + '\n' + '# If you wont to see at work set appcache: true' + '\n' + '# in config.json and start cloudcmd.js' + '\n' + - '# http://github.com/coderaiser/cloudcmd' + '\n'); + '# http://coderaiser.github.com/cloudcmd' + '\n'); var main = global.cloudcmd.main, fs = main.fs, diff --git a/lib/server/auth.js b/lib/server/auth.js index 04f56c83..ce0b284c 100644 --- a/lib/server/auth.js +++ b/lib/server/auth.js @@ -12,7 +12,7 @@ '# parameters in config.json or environment' + '\n' + '# and start cloudcmd.js or just do' + '\n' + '# require(\'auth.js\').auth(pCode, pCallBack)' + '\n' + - '# http://github.com/coderaiser/cloudcmd' + '\n'); + '# http://coderaiser.github.com/cloudcmd' + '\n'); var main = global.cloudcmd.main, diff --git a/lib/server/rest.js b/lib/server/rest.js index f9a7b1e8..c963251f 100644 --- a/lib/server/rest.js +++ b/lib/server/rest.js @@ -11,7 +11,7 @@ '# used for work with REST API.' + '\n' + '# If you wont to see at work set rest: true' + '\n' + '# and api_url in config.json' + '\n' + - '# http://github.com/coderaiser/cloudcmd' + '\n'); + '# http://coderaiser.github.com/cloudcmd' + '\n'); var main = global.cloudcmd.main, Util = main.util, diff --git a/lib/server/update.js b/lib/server/update.js index 0413be55..e0ac486a 100644 --- a/lib/server/update.js +++ b/lib/server/update.js @@ -10,7 +10,7 @@ '# Module is part of Cloud Commander,' + '\n' + '# used for work update thru git.' + '\n' + '# If you wont to see at work install git' + '\n' + - '# http://github.com/coderaiser/cloudcmd' + '\n'); + '# http://coderaiser.github.com/cloudcmd' + '\n'); var main = global.cloudcmd.main, mainpackage = main.mainpackage, @@ -35,7 +35,7 @@ * @param pStdout * @param pStderr */ - function pull(pError, pStdout, pStderr){ + function pull(pError, pStdout, pStderr){ var lExec; if(!pError){ diff --git a/lib/server/win.js b/lib/server/win.js index 87655191..6d02489e 100644 --- a/lib/server/win.js +++ b/lib/server/win.js @@ -1,3 +1,75 @@ -/* Library contain windows specific functions +/* + * Library contain windows specific functions * like getting information about volumes - */ \ No newline at end of file + */ + +(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, + + SRVDIR = main.SRVDIR, + BATDIR = SRVDIR + 'win\\', + GETVOLUMES = BATDIR + 'getvolumes', + BAT = GETVOLUMES + '.bat', + SCENARIO = GETVOLUMES + '.txt', + StdOut, + exec = main.child_process.exec, + Util = main.util; + + + /** + * get position of current name of volume + * @param pNumber = number of volume + */ + function getPosition(pNumber){ + var lRet, + lstrPattern = 'Том '; + + lRet = StdOut.indexOf(lstrPattern + pNumber); + + return lRet; + } + + /** + * get name of volume + * @param pPosition - current char position + */ + function getVolumeName(pPosition){ + var lRet, + lCharPosition = 10; + + lRet = StdOut[pPosition + lCharPosition]; + + return lRet; + } + + + exec(BAT + ' -s ' + SCENARIO, processOuput); + + + function processOuput(pError, pStdout, pStderr){ + StdOut = pStdout; + if(!pError){ + var lVolumes = [], + i = 0, + lNum = getPosition(i); + + do{ + lVolumes[i] = getVolumeName(lNum); + lNum = getPosition(++i); + }while(lNum > 0); + } + else + Util.log(pError); + } +})();