feature(win) diskpart -> wmic

This commit is contained in:
coderaiser 2013-07-22 14:23:38 +00:00
parent 61d114c575
commit 28ebbe234d
4 changed files with 19 additions and 55 deletions

View file

@ -124,6 +124,8 @@ getJSONfromFileTable.
* feature(main) add to exports checkCallBackParams
* feature(win) diskpart -> wmic
2012.04.22, v0.2.0
* Added alerting about errors.

View file

@ -15,7 +15,6 @@
'# functions like work with drives(etc c).' + '\n' +
'# http://coderaiser.github.com/cloudcmd' + '\n');
var main = global.cloudcmd.main,
Charset ={
UNICODE : 65001,
@ -27,67 +26,32 @@
exports.getVolumes = function(pCallBack){
var SRVDIR = main.SRVDIR,
BATDIR = SRVDIR + 'win\\',
SCENARIO = BATDIR + 'getvolumes.txt',
lCHCP = 'chcp ' + Charset.UNICODE,
lDiskPart = 'diskpart -s "' + SCENARIO + '"';
var lCHCP = 'chcp ' + Charset.UNICODE,
lGetVolumes = 'wmic logicaldisk get name'
exec(lCHCP + ' && ' + lDiskPart, retProcessOuput(pCallBack));
exec(lCHCP + ' && ' + lGetVolumes, retProcessOuput(pCallBack));
};
function retProcessOuput(pCallBack){
return function(pError, pStdout, pStderr){
var lstrPattern = 'Том ',
lCharPosition = 10;
/**
* get position of current name of volume
* @param pNumber = number of volume
*/
var getPosition = function(pNumber){
var lRet = pStdout.indexOf(lstrPattern + pNumber);
return lRet;
};
/**
* get name of volume
* @param pPosition - current char position
*/
var getVolumeName = function (pPosition){
var lRet = pStdout[pPosition + lCharPosition];
return lRet;
};
var lVolumes = [];
var lRemoveStr = [
'\r', '\n',
'Name',
'Active code page: 65001 '
],
lVolumes = [],
lError = pError || pStderr;
exec('chcp ' + Charset.WIN32);
if(!pError){
var i = 0,
lNum = getPosition(i);
/* if russian name not found
* try to search english name
*/
if(lNum < 0){
lstrPattern = 'Volume ',
lCharPosition = 10 + 3;
lNum = getPosition(i);
}
do{
lVolumes[i] = getVolumeName(lNum);
lNum = getPosition(++i);
}while(lNum > 0);
if(!lError) {
lVolumes = Util.removeStr(pStdout, lRemoveStr)
.split(' ')
lVolumes.pop();
}
else
Util.log(pError);
Util.exec(pCallBack, lVolumes);
Util.exec(pCallBack, lError || lVolumes);
};
}
})();

View file

@ -1 +0,0 @@
diskpart /s getvolumes.txt

View file

@ -1 +0,0 @@
list volume