Changeset 8505
- Timestamp:
- 2004-11-10T12:50:45+13:00 (19 years ago)
- Location:
- trunk/gli/src/org/greenstone/gatherer/file
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/file/FileQueue.java
r8313 r8505 342 342 // Nothing else can be done by the Gatherer. In fact if we are really out of space I'm not even sure we can quit safely. 343 343 } 344 catch (ReadNotPermittedException rnp_exception) { 345 if (DebugStream.isDebuggingEnabled()) { 346 DebugStream.printStackTrace(rnp_exception); 347 } 348 cancel_action = true; 349 // Show warning 350 JOptionPane.showMessageDialog(Gatherer.g_man, Dictionary.get("FileActions.Read_Not_Permitted_Message", source_file.getAbsolutePath()), Dictionary.get("FileActions.Write_Not_Permitted_Title"), JOptionPane.ERROR_MESSAGE); 351 // Nothing else we can do. 352 } 344 353 catch(UnknownFileErrorException ufe_exception) { 345 354 DebugStream.printStackTrace(ufe_exception); … … 350 359 } 351 360 catch(WriteNotPermittedException wnp_exception) { 352 DebugStream.printStackTrace(wnp_exception); 361 if (DebugStream.isDebuggingEnabled()) { 362 DebugStream.printStackTrace(wnp_exception); 363 } 353 364 cancel_action = true; 354 365 // Show warning … … 632 643 */ 633 644 public void copyDirectoryContents(File source, File destination, LongProgressBar progress) 634 throws FileAlreadyExistsException, FileNotFoundException, InsufficientSpaceException, IOException, UnknownFileErrorException, WriteNotPermittedException645 throws FileAlreadyExistsException, FileNotFoundException, InsufficientSpaceException, IOException, ReadNotPermittedException, UnknownFileErrorException, WriteNotPermittedException 635 646 { 636 647 if (!source.isDirectory()) return; … … 659 670 */ 660 671 public void copyFile(File source, File destination, LongProgressBar progress) 661 throws FileAlreadyExistsException, FileNotFoundException, InsufficientSpaceException, IOException, UnknownFileErrorException, WriteNotPermittedException {672 throws FileAlreadyExistsException, FileNotFoundException, InsufficientSpaceException, IOException, ReadNotPermittedException, UnknownFileErrorException, WriteNotPermittedException { 662 673 if(source.isDirectory()) { 663 674 destination.mkdirs(); … … 665 676 else { 666 677 // Check if the origin file exists. 667 if (!source.exists()) {678 if (!source.exists()) { 668 679 DebugStream.println("Couldn't find the source file."); 669 680 throw(new FileNotFoundException()); 670 681 } 671 // Check if the destination file does not exist. 672 if(destination.exists()) { 682 683 // Make sure the destination file does not exist. 684 if (destination.exists()) { 673 685 throw(new FileAlreadyExistsException()); 674 686 } 687 688 // Open an input stream to the source file 689 FileInputStream f_in = null; 690 try { 691 f_in = new FileInputStream(source); 692 } 693 catch (FileNotFoundException exception) { 694 // A FileNotFoundException translates into a ReadNotPermittedException in this case 695 throw new ReadNotPermittedException(exception.toString()); 696 } 697 698 // Create an necessary directories for the target file 675 699 File dirs = destination.getParentFile(); 676 700 dirs.mkdirs(); 677 // Copy the file. 678 FileInputStream f_in = new FileInputStream(source);701 702 // Open an output stream to the target file 679 703 FileOutputStream f_out = null; 680 // This may throw a file not found exception, but this translates to a WriteNotPermittedException, in this case681 704 try { 682 705 f_out = new FileOutputStream(destination); 683 706 } 684 707 catch (FileNotFoundException exception) { 708 // A FileNotFoundException translates into a WriteNotPermittedException in this case 685 709 throw new WriteNotPermittedException(exception.toString()); 686 710 } 711 712 // Copy the file 687 713 byte data[] = new byte[Utility.BUFFER_SIZE]; 688 714 int data_size = 0;
Note:
See TracChangeset
for help on using the changeset viewer.