Lines 57-62
Link Here
|
57 |
import java.io.BufferedOutputStream; |
57 |
import java.io.BufferedOutputStream; |
58 |
import java.io.File; |
58 |
import java.io.File; |
59 |
import java.io.FileInputStream; |
59 |
import java.io.FileInputStream; |
|
|
60 |
import java.io.FileNotFoundException; |
60 |
import java.io.FileOutputStream; |
61 |
import java.io.FileOutputStream; |
61 |
import java.io.IOException; |
62 |
import java.io.IOException; |
62 |
import java.io.InputStream; |
63 |
import java.io.InputStream; |
Lines 674-695
Link Here
|
674 |
|
688 |
|
675 |
if (monitor!=null){ |
689 |
if (monitor!=null){ |
676 |
if (monitor.isCanceled()) { |
690 |
if (monitor.isCanceled()) { |
677 |
return false; |
691 |
throw new RemoteFileCancelledException(); |
678 |
} |
692 |
} |
679 |
} |
693 |
} |
680 |
|
694 |
|
681 |
IHostFile remoteHostFile = getFile(remoteParent,remoteFile,null); |
695 |
IHostFile remoteHostFile = getFile(remoteParent,remoteFile,null); |
682 |
|
696 |
|
683 |
if(remoteHostFile == null) |
|
|
684 |
{ |
685 |
return false; |
686 |
} |
687 |
|
688 |
if(!remoteHostFile.exists()) |
689 |
{ |
690 |
throw new RemoteFileIOException(new Exception(FTPServiceResources.FTPService_FTP_File_Service_Not_Found)); |
691 |
} |
692 |
|
693 |
if(_commandMutex.waitForLock(monitor, Long.MAX_VALUE)) |
697 |
if(_commandMutex.waitForLock(monitor, Long.MAX_VALUE)) |
694 |
{ |
698 |
{ |
695 |
try |
699 |
try |
Lines 703-723
Link Here
|
703 |
|
707 |
|
704 |
ftpClient.changeWorkingDirectory(remoteParent); |
708 |
ftpClient.changeWorkingDirectory(remoteParent); |
705 |
setFileType(isBinary); |
709 |
setFileType(isBinary); |
706 |
if (!localFile.exists()) |
|
|
707 |
{ |
708 |
File localParentFile = localFile.getParentFile(); |
709 |
if (!localParentFile.exists()) |
710 |
{ |
711 |
localParentFile.mkdirs(); |
712 |
} |
713 |
localFile.createNewFile(); |
714 |
} |
715 |
|
710 |
|
716 |
output = new FileOutputStream(localFile); |
|
|
717 |
input = ftpClient.retrieveFileStream(remoteFile); |
711 |
input = ftpClient.retrieveFileStream(remoteFile); |
718 |
|
712 |
|
719 |
if(input != null) |
713 |
if(input != null) |
720 |
{ |
714 |
{ |
|
|
715 |
if (!localFile.exists()) |
716 |
{ |
717 |
File localParentFile = localFile.getParentFile(); |
718 |
if (!localParentFile.exists()) |
719 |
{ |
720 |
localParentFile.mkdirs(); |
721 |
} |
722 |
localFile.createNewFile(); |
723 |
} |
724 |
|
725 |
output = new FileOutputStream(localFile); |
721 |
progressMonitor.init(0, remoteFile, localFile.getName(), remoteHostFile.getSize()); |
726 |
progressMonitor.init(0, remoteFile, localFile.getName(), remoteHostFile.getSize()); |
722 |
byte[] buffer = new byte[4096]; |
727 |
byte[] buffer = new byte[4096]; |
723 |
int readCount; |
728 |
int readCount; |
Lines 740-751
Link Here
|
740 |
output.close(); |
745 |
output.close(); |
741 |
|
746 |
|
742 |
ftpClient.completePendingCommand(); |
747 |
ftpClient.completePendingCommand(); |
|
|
748 |
|
749 |
} |
750 |
else |
751 |
{ |
752 |
throw new RemoteFileIOException(new Exception(ftpClient.getReplyString())); |
743 |
} |
753 |
} |
744 |
} |
754 |
} |
745 |
catch (Exception e) |
755 |
catch (FileNotFoundException e) |
|
|
756 |
{ |
757 |
throw new RemoteFileIOException(e); |
758 |
} |
759 |
catch (IOException e) |
746 |
{ |
760 |
{ |
747 |
throw new RemoteFileIOException(e); |
761 |
throw new RemoteFileIOException(e); |
748 |
} finally |
762 |
} |
|
|
763 |
finally |
749 |
{ |
764 |
{ |
750 |
_commandMutex.release(); |
765 |
_commandMutex.release(); |
751 |
} |
766 |
} |