mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-19 09:24:51 +00:00
feature(dom) add pack, unpack -> twopack
This commit is contained in:
parent
c78ad8dc98
commit
6fd7134c52
1 changed files with 42 additions and 17 deletions
|
|
@ -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
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue