Changeset 9095 for trunk/gli/src/org/greenstone/gatherer/util/Utility.java
- Timestamp:
- 2005-02-18T12:31:54+13:00 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/util/Utility.java
r9045 r9095 49 49 import org.greenstone.gatherer.DebugStream; 50 50 import org.greenstone.gatherer.Dictionary; 51 import org.greenstone.gatherer.shell.GShell; 51 52 // Don't even think about adding import org.greenstone.gatherer.Gatherer in here! 52 53 // The functions in this class should be independent of the Gatherer class. Put your function somewhere else buster! … … 601 602 } 602 603 603 static protected void zipFunc (ZipOutputStream zos, String file_path, int prefix_strip )604 static protected void zipFunc (ZipOutputStream zos, String file_path, int prefix_strip, GShell source) 604 605 { 605 606 // Using try is required because of file io. 606 607 try { 608 // Exit if pressed cancel. 609 if (source != null && source.hasSignalledStop()) { 610 return; 611 } 607 612 // Create a Zip Entry and put it into the archive (no data yet). 608 613 … … 624 629 // to the zip output stream until the bis has been entirely read. 625 630 while ((byteCount = bis.read(data, 0, 1024)) > -1) { 631 //Check for cancell 632 if(source != null) { 633 if(source.hasSignalledStop()) { 634 break; 635 } 636 } 626 637 zos.write(data, 0, byteCount); 627 638 } … … 634 645 } 635 646 636 static protected void dirFunc (ZipOutputStream zos, String dir_name, int prefix_strip )647 static protected void dirFunc (ZipOutputStream zos, String dir_name, int prefix_strip, GShell source) 637 648 { 638 649 File dirObj = new File(dir_name); … … 645 656 // Loop through File array and display. 646 657 for (int i = 0; i < fileList.length; i++) { 658 if(source != null) { 659 if(source.hasSignalledStop()) { 660 break; 661 } 662 } 647 663 File file = fileList[i]; 648 664 if (file.isDirectory()) { … … 661 677 } 662 678 663 dirFunc(zos,dir_path,prefix_strip );679 dirFunc(zos,dir_path,prefix_strip, source); 664 680 } else if (file.isFile()) { 665 681 // Call the zipFunc function 666 682 String file_path = fileList[i].getPath(); 667 zipFunc(zos,file_path,prefix_strip );683 zipFunc(zos,file_path,prefix_strip, source); 668 684 } 669 685 } … … 680 696 681 697 682 static public void zipup(String col_dir, String col_name, String dir_or_file )698 static public void zipup(String col_dir, String col_name, String dir_or_file, GShell source) 683 699 { 684 700 int prefix_strip = col_dir.length(); … … 695 711 if (zip_dof.isDirectory()) { 696 712 String zip_dir = zip_dir_or_file; 697 dirFunc(zos,zip_dir,prefix_strip );713 dirFunc(zos,zip_dir,prefix_strip, source); 698 714 } 699 715 else { … … 714 730 } 715 731 } 716 zipFunc(zos,zip_full_file,prefix_strip );732 zipFunc(zos,zip_full_file,prefix_strip, source); 717 733 } 718 734 } … … 728 744 catch (IOException exception) { 729 745 DebugStream.printStackTrace(exception); 730 } 746 } 731 747 } 732 748
Note:
See TracChangeset
for help on using the changeset viewer.