Changeset 5079
- Timestamp:
- 2003-08-04T11:32:49+12:00 (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/file/FileQueue.java
r4675 r5079 1 package org.greenstone.gatherer.file;2 1 /** 3 2 *######################################################################### … … 7 6 * University of Waikato, New Zealand. 8 7 * 9 * <BR><BR>10 *11 8 * Author: John Thompson, Greenstone Digital Library, University of Waikato 12 9 * 13 * <BR><BR>14 *15 10 * Copyright (C) 1999 New Zealand Digital Library Project 16 *17 * <BR><BR>18 11 * 19 12 * This program is free software; you can redistribute it and/or modify … … 22 15 * (at your option) any later version. 23 16 * 24 * <BR><BR>25 *26 17 * This program is distributed in the hope that it will be useful, 27 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of 28 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 29 20 * GNU General Public License for more details. 30 *31 * <BR><BR>32 21 * 33 22 * You should have received a copy of the GNU General Public License … … 36 25 *######################################################################## 37 26 */ 27 package org.greenstone.gatherer.file; 28 38 29 import java.io.*; 39 30 import java.util.*; … … 327 318 // Nothing else we can do. 328 319 } 320 catch(WriteNotPermittedException wnp_exception) { 321 Gatherer.printStackTrace(wnp_exception); 322 cancel_action = true; 323 // Show warning 324 JOptionPane.showMessageDialog(Gatherer.g_man, get("Write_Not_Permitted_Message", target_file.getAbsolutePath()), get("Write_Not_Permitted_Title"), JOptionPane.ERROR_MESSAGE); 325 // Nothing else we can do. 326 } 329 327 catch(IOException exception) { 330 328 // Can't really do much about this. … … 669 667 */ 670 668 public void copyFile(File source, File destination, LongProgressBar progress) 671 throws FileAlreadyExistsException, FileNotFoundException, InsufficientSpaceException, IOException, UnknownFileErrorException {669 throws FileAlreadyExistsException, FileNotFoundException, InsufficientSpaceException, IOException, UnknownFileErrorException, WriteNotPermittedException { 672 670 if(source.isDirectory()) { 673 671 destination.mkdirs(); … … 676 674 // Check if the origin file exists. 677 675 if(!source.exists()) { 676 System.err.println("Couldn't find the source file."); 678 677 throw(new FileNotFoundException()); 679 678 } … … 686 685 // Copy the file. 687 686 FileInputStream f_in = new FileInputStream(source); 688 FileOutputStream f_out = new FileOutputStream(destination); 687 FileOutputStream f_out = null; 688 // This may throw a file not found exception, but this translates to a WriteNotPermittedException, in this case 689 try { 690 f_out = new FileOutputStream(destination); 691 } 692 catch (FileNotFoundException exception) { 693 throw new WriteNotPermittedException(exception.toString()); 694 } 689 695 byte data[] = new byte[Utility.BUFFER_SIZE]; 690 696 int data_size = 0; … … 711 717 } 712 718 } 713 719 // Flush and close the streams to ensure all bytes are written. 714 720 f_in.close(); 715 721 f_out.close(); 716 717 if(! cancel_action && source.length() != destination.length()) {722 // We have now, in theory, produced an exact copy of the source file. Check this by comparing sizes. 723 if(!destination.exists() || (!cancel_action && source.length() != destination.length())) { 718 724 throw(new UnknownFileErrorException()); 719 725 } 720 726 // If we were cancelled, ensure that none of the destination file exists. 721 727 if(cancel_action) { 722 728 destination.delete();
Note:
See TracChangeset
for help on using the changeset viewer.