|
602 | 602 | if(abs.startsWith('/')){ |
603 | 603 | abs = abs.slice(1); |
604 | 604 | } |
605 | | - zip.file(abs,blob); |
| 605 | + |
| 606 | + archive.file.add(abs,path); |
| 607 | + |
606 | 608 | display(path); |
607 | 609 |
|
608 | 610 | return false; |
|
615 | 617 | if(path.startsWith('/')){ |
616 | 618 | path = path.slice(1); |
617 | 619 | } |
618 | | - var blob = await zip.file(path).async('blob'); |
619 | | - |
620 | | - console.log(blob); |
621 | 620 |
|
| 621 | + var blob = await archive.file.read(path); |
| 622 | + console.log(blob); |
622 | 623 | return {blob}; |
623 | 624 |
|
624 | 625 | }//download |
|
646 | 647 | if(abs.startsWith('/')){ |
647 | 648 | abs = abs.slice(1); |
648 | 649 | } |
649 | | - zip.folder(abs); |
| 650 | + |
| 651 | + archive.dir.add(path); |
650 | 652 |
|
651 | 653 | display(path); |
652 | 654 |
|
|
661 | 663 | if(abs.startsWith('/')){ |
662 | 664 | abs = abs.slice(1); |
663 | 665 | } |
664 | | - zip.remove(abs); |
| 666 | + |
| 667 | + archive.dir.rem(abs); |
| 668 | + |
665 | 669 | display(path); |
666 | 670 |
|
667 | 671 | return false; |
|
674 | 678 | var list = read(path); |
675 | 679 | list = list.filter(fn=>fn.startsWith(path)); |
676 | 680 | list = list.filter(Boolean); |
677 | | - |
678 | | - console.json(list); |
679 | | - |
| 681 | + console.json(list); |
680 | 682 | /* |
681 | 683 | list.forEach(fn=>{ |
682 | 684 | |
|
714 | 716 | var path = filenav.cur.path+filenav.cur.name; |
715 | 717 | path = path.slice(1); |
716 | 718 | 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); |
723 | 720 | console.log(blob); |
724 | 721 | return blob; |
725 | 722 |
|
|
794 | 791 | }//rem |
795 | 792 |
|
796 | 793 |
|
| 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 | + |
797 | 816 |
|
798 | 817 | //archive.zip: |
799 | 818 |
|
| 819 | + |
800 | 820 | archive.zip.new = function(){ |
801 | 821 |
|
802 | 822 | archive.cur = new jszip(); |
|
806 | 826 |
|
807 | 827 | archive.zip.blob = async function(){ |
808 | 828 |
|
809 | | - var blob = await zip.generateAsync({type:'blob'}); |
| 829 | + var blob = await archive.cur.generateAsync({type:'blob'}); |
810 | 830 | return blob; |
811 | 831 |
|
812 | 832 | }//blob |
|
829 | 849 |
|
830 | 850 | archive.zip.file.add = function(path,blob){ |
831 | 851 |
|
832 | | - zip.file(path,blob); |
| 852 | + archive.cur.file(path,blob); |
833 | 853 |
|
834 | 854 | }//file |
835 | 855 |
|
836 | 856 |
|
837 | 857 | archive.zip.file.rem = function(path){ |
838 | 858 |
|
839 | | - zip.remove(abs); |
| 859 | + archive.cur.remove(abs); |
840 | 860 |
|
841 | 861 | }//rem |
842 | 862 |
|
843 | 863 |
|
| 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 | + |
844 | 891 | //: |
845 | 892 |
|
846 | 893 |
|
|
0 commit comments