Skip to content

Commit a810fd6

Browse files
save file
1 parent 1919b0e commit a810fd6

1 file changed

Lines changed: 65 additions & 18 deletions

File tree

utils/misc/zip/v3.0/zip-v3.0.html

Lines changed: 65 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,9 @@
602602
if(abs.startsWith('/')){
603603
abs = abs.slice(1);
604604
}
605-
zip.file(abs,blob);
605+
606+
archive.file.add(abs,path);
607+
606608
display(path);
607609

608610
return false;
@@ -615,10 +617,9 @@
615617
if(path.startsWith('/')){
616618
path = path.slice(1);
617619
}
618-
var blob = await zip.file(path).async('blob');
619-
620-
console.log(blob);
621620

621+
var blob = await archive.file.read(path);
622+
console.log(blob);
622623
return {blob};
623624

624625
}//download
@@ -646,7 +647,8 @@
646647
if(abs.startsWith('/')){
647648
abs = abs.slice(1);
648649
}
649-
zip.folder(abs);
650+
651+
archive.dir.add(path);
650652

651653
display(path);
652654

@@ -661,7 +663,9 @@
661663
if(abs.startsWith('/')){
662664
abs = abs.slice(1);
663665
}
664-
zip.remove(abs);
666+
667+
archive.dir.rem(abs);
668+
665669
display(path);
666670

667671
return false;
@@ -674,9 +678,7 @@
674678
var list = read(path);
675679
list = list.filter(fn=>fn.startsWith(path));
676680
list = list.filter(Boolean);
677-
678-
console.json(list);
679-
681+
console.json(list);
680682
/*
681683
list.forEach(fn=>{
682684
@@ -714,12 +716,7 @@
714716
var path = filenav.cur.path+filenav.cur.name;
715717
path = path.slice(1);
716718
console.log(path);
717-
var zf = zip.file(path);
718-
if(!zf){
719-
log.red(path+' not found');
720-
return;
721-
}
722-
var blob = await zf.async('blob');
719+
var blob = await archive.file.read(path);
723720
console.log(blob);
724721
return blob;
725722

@@ -794,9 +791,32 @@
794791
}//rem
795792

796793

794+
archive.file.read = async function(path){
795+
796+
var result = await archive[archive.type].file.read(path);
797+
return result;
798+
799+
}//read
800+
801+
802+
archive.dir.add = function(path){
803+
804+
archive[archive.type].dir.add(path);
805+
806+
}//add
807+
808+
809+
archive.dir.rem = function(path){
810+
811+
archive[archive.type].dir.rem(path);
812+
813+
}//rem
814+
815+
797816

798817
//archive.zip:
799818

819+
800820
archive.zip.new = function(){
801821

802822
archive.cur = new jszip();
@@ -806,7 +826,7 @@
806826

807827
archive.zip.blob = async function(){
808828

809-
var blob = await zip.generateAsync({type:'blob'});
829+
var blob = await archive.cur.generateAsync({type:'blob'});
810830
return blob;
811831

812832
}//blob
@@ -829,18 +849,45 @@
829849

830850
archive.zip.file.add = function(path,blob){
831851

832-
zip.file(path,blob);
852+
archive.cur.file(path,blob);
833853

834854
}//file
835855

836856

837857
archive.zip.file.rem = function(path){
838858

839-
zip.remove(abs);
859+
archive.cur.remove(abs);
840860

841861
}//rem
842862

843863

864+
archive.zip.file.read = async function(path){
865+
866+
var zf = archive.cur.file(path);
867+
if(!zf){
868+
return;
869+
}
870+
var blob = await zf.async('blob');
871+
return blob;
872+
873+
}//read
874+
875+
876+
archive.zip.dir.add = function(path){
877+
878+
archive.cur.folder(abs);
879+
880+
}//add
881+
882+
883+
archive.zip.dir.rem = function(path){
884+
885+
archive.cur.remove(abs);
886+
887+
}//rem
888+
889+
890+
844891
//:
845892

846893

0 commit comments

Comments
 (0)