mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-18 17:05:17 +00:00
refactor(win) mv isVolume, isChangeVolume
This commit is contained in:
parent
bc6b814517
commit
d2908cc08d
2 changed files with 39 additions and 26 deletions
|
|
@ -5,6 +5,9 @@
|
|||
|
||||
socket = main.socket,
|
||||
update = main.srvrequire('update'),
|
||||
DIR = '../',
|
||||
DIR_SERVER = './',
|
||||
win = require(DIR_SERVER + 'win'),
|
||||
|
||||
exec = main.child_process.exec,
|
||||
spawn = main.child_process.spawn,
|
||||
|
|
@ -97,7 +100,7 @@
|
|||
var funcExec, firstChar,
|
||||
connName, ret, isContain,
|
||||
|
||||
isVolume = isChangeWinVolume(command),
|
||||
isVolume = win.isChangeVolume(command),
|
||||
|
||||
symbolsExec = ['*', '&', '{', '}', '|', '\'', '"'],
|
||||
CWD = process.cwd(),
|
||||
|
|
@ -265,8 +268,8 @@
|
|||
}
|
||||
|
||||
function onCD(command, currDir, callback) {
|
||||
var isChangeVolume = isChangeWinVolume(command),
|
||||
isVolume = isWinVolume(command),
|
||||
var isChangeVolume = win.isChangeVolume(command),
|
||||
isVolume = win.isVolume(command),
|
||||
paramDir = Util.rmStr(command, 'cd '),
|
||||
isRootOrHome = equalPart(paramDir, ['/', '~']),
|
||||
getDir = WIN32 ? 'chdir' : 'pwd';
|
||||
|
|
@ -291,28 +294,6 @@
|
|||
});
|
||||
}
|
||||
|
||||
function isWinVolume(command) {
|
||||
var is, winVolume;
|
||||
|
||||
if (WIN32) {
|
||||
winVolume = new RegExp('^[a-z]{1}:\\\\.*', 'i');
|
||||
is = command.match(winVolume);
|
||||
}
|
||||
|
||||
return is;
|
||||
}
|
||||
|
||||
function isChangeWinVolume(command) {
|
||||
var is, winVolume;
|
||||
|
||||
if (WIN32) {
|
||||
winVolume = new RegExp('^[a-z]{1}:$', 'i');
|
||||
is = command.match(winVolume);
|
||||
}
|
||||
|
||||
return is;
|
||||
}
|
||||
|
||||
function log(connNum, str, typeParam) {
|
||||
var ret,
|
||||
type = ' ';
|
||||
|
|
|
|||
|
|
@ -18,11 +18,17 @@
|
|||
DIR = '../',
|
||||
DIR_SERVER = DIR + 'server/',
|
||||
Util = require(DIR + 'util'),
|
||||
pipe = require(DIR_SERVER + 'pipe');
|
||||
pipe = require(DIR_SERVER + 'pipe'),
|
||||
|
||||
WIN = process.platform === 'win32',
|
||||
WIN_VOLUME = '^[a-z]{1}:$';
|
||||
|
||||
exports.getVolumes = getVolumes;
|
||||
exports.prepareCodePage = prepareCodePage;
|
||||
|
||||
exports.isVolume = isVolume;
|
||||
exports.isChangeVolume = isChangeVolume;
|
||||
|
||||
function getVolumes(callback) {
|
||||
var wmic = spawn('wmic', ['logicaldisk', 'get', 'name']);
|
||||
|
||||
|
|
@ -98,4 +104,30 @@
|
|||
});
|
||||
}
|
||||
|
||||
function isVolume(command) {
|
||||
var is, winVolume;
|
||||
|
||||
Util.checkArgs(arguments, ['command']);
|
||||
|
||||
if (WIN) {
|
||||
winVolume = new RegExp(WIN_VOLUME + '\\\\.*', 'i');
|
||||
is = command.match(winVolume);
|
||||
}
|
||||
|
||||
return is;
|
||||
}
|
||||
|
||||
function isChangeVolume(command) {
|
||||
var is, winVolume;
|
||||
|
||||
Util.checkArgs(arguments, ['command']);
|
||||
|
||||
if (WIN) {
|
||||
winVolume = new RegExp(WIN_VOLUME, 'i');
|
||||
is = command.match(winVolume);
|
||||
}
|
||||
|
||||
return is;
|
||||
}
|
||||
|
||||
})();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue