mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-20 18:18:56 +00:00
feature(win) diskpart -> wmic
This commit is contained in:
parent
6a45f4b26d
commit
138628d735
4 changed files with 19 additions and 55 deletions
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
};
|
||||
}
|
||||
})();
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
diskpart /s getvolumes.txt
|
||||
|
|
@ -1 +0,0 @@
|
|||
list volume
|
||||
Loading…
Add table
Add a link
Reference in a new issue