feature(dom) add pack, unpack -> twopack

This commit is contained in:
coderaiser 2014-09-18 03:35:55 -04:00
parent c78ad8dc98
commit 6fd7134c52

View file

@ -448,12 +448,12 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
RESTful.write(lDir + lName + lType, null, CloudCmd.refresh);
}
/**
* zip file
*
*/
this.pack = function(current) {
var RESTful = DOM.RESTful,
function twopack(current, operation) {
var op,
nameDir = '',
nameFile = '',
RESTful = DOM.RESTful,
Images = DOM.Images,
name = Cmd.getCurrentName(current),
dir = Cmd.getCurrentDirPath(),
path = dir + name,
@ -461,8 +461,40 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
from : path
};
Util.checkArgs(arguments, ['operation']);
if (operation.pack) {
op = RESTful.zip;
nameDir = name + '.tar.gz';
nameFile = name + '.gz';
} else if (operation.unpack) {
op = RESTful.unzip;
nameDir = Util.rmStrOnce(name, '.tar.gz');
nameFile = Util.rmStrOnce(name, '.gz');
}
Images.showLoad();
if (name && name !== '..')
RESTful.zip(fileFrom, CloudCmd.refresh);
op(fileFrom, function() {
CloudCmd.refresh(null, null, function() {
var byName = DOM.getCurrentFileByName,
dir = byName(nameDir),
file = byName(nameFile);
DOM.setCurrentFile(dir || file);
});
});
}
/**
* zip file
*
*/
this.pack = function(current) {
twopack(current, {
pack: true
});
};
/**
@ -470,16 +502,9 @@ var CloudCmd, Util, DOM, CloudFunc, Dialog;
*
*/
this.unpack = function(current) {
var RESTful = DOM.RESTful,
name = Cmd.getCurrentName(current),
dir = Cmd.getCurrentDirPath(),
path = dir + name,
fileFrom = {
from : path
};
if (name && name !== '..')
RESTful.unzip(fileFrom, CloudCmd.refresh);
twopack(current, {
unpack: true
});
};
/**