Subversion Repository Public Repository

litesoft

Diff Revisions 958 vs 959 for /trunk/Java/ScarPlus/src/com/esotericsoftware/scar/FTP.java

Diff revisions: vs.
  @@ -1,72 +1,58 @@
1 - package com.esotericsoftware.scar;
2 -
3 - import org.apache.commons.net.ftp.*;
4 -
5 - import com.esotericsoftware.filesystem.*;
6 - import com.esotericsoftware.utils.*;
7 -
8 - import java.io.*;
9 - import java.net.*;
10 -
11 - import static com.esotericsoftware.minlog.Log.*;
12 -
13 - public class FTP
14 - {
15 - static public boolean upload( String server, String user, String password, String dir, Paths paths, boolean passive )
16 - {
17 - try
18 - {
19 - FTPClient ftp = new FTPClient();
20 - InetAddress address = InetAddress.getByName( server );
21 - if ( DEBUG )
22 - {
23 - debug( "Connecting to FTP server: " + address );
24 - }
25 - ftp.connect( address );
26 - if ( passive )
27 - {
28 - ftp.enterLocalPassiveMode();
29 - }
30 - if ( !ftp.login( user, password ) )
31 - {
32 - if ( ERROR )
33 - {
34 - error( "FTP login failed for user: " + user );
35 - }
36 - return false;
37 - }
38 - if ( !ftp.changeWorkingDirectory( dir ) )
39 - {
40 - if ( ERROR )
41 - {
42 - error( "FTP directory change failed: " + dir );
43 - }
44 - return false;
45 - }
46 - ftp.setFileType( org.apache.commons.net.ftp.FTP.BINARY_FILE_TYPE );
47 - for ( String path : paths.getFullPaths() )
48 - {
49 - if ( INFO )
50 - {
51 - info( "FTP upload: " + path );
52 - }
53 - BufferedInputStream input = new BufferedInputStream( new FileInputStream( path ) );
54 - try
55 - {
56 - ftp.storeFile( new File( path ).getName(), input );
57 - }
58 - finally
59 - {
60 - FileUtil.dispose( input );
61 - }
62 - }
63 - ftp.logout();
64 - ftp.disconnect();
65 - }
66 - catch ( IOException e )
67 - {
68 - throw new WrappedIOException( e );
69 - }
70 - return true;
71 - }
72 - }
1 + package com.esotericsoftware.scar;
2 +
3 + import org.apache.commons.net.ftp.*;
4 +
5 + import com.esotericsoftware.filesystem.*;
6 + import com.esotericsoftware.utils.*;
7 +
8 + import java.io.*;
9 + import java.net.*;
10 +
11 + import static com.esotericsoftware.minlog.Log.*;
12 +
13 + public class FTP {
14 + static public boolean upload( String server, String user, String password, String dir, Paths paths, boolean passive ) {
15 + try {
16 + FTPClient ftp = new FTPClient();
17 + InetAddress address = InetAddress.getByName( server );
18 + if ( DEBUG ) {
19 + debug( "Connecting to FTP server: " + address );
20 + }
21 + ftp.connect( address );
22 + if ( passive ) {
23 + ftp.enterLocalPassiveMode();
24 + }
25 + if ( !ftp.login( user, password ) ) {
26 + if ( ERROR ) {
27 + error( "FTP login failed for user: " + user );
28 + }
29 + return false;
30 + }
31 + if ( !ftp.changeWorkingDirectory( dir ) ) {
32 + if ( ERROR ) {
33 + error( "FTP directory change failed: " + dir );
34 + }
35 + return false;
36 + }
37 + ftp.setFileType( org.apache.commons.net.ftp.FTP.BINARY_FILE_TYPE );
38 + for ( String path : paths.getFullPaths() ) {
39 + if ( INFO ) {
40 + info( "FTP upload: " + path );
41 + }
42 + BufferedInputStream input = new BufferedInputStream( new FileInputStream( path ) );
43 + try {
44 + ftp.storeFile( new File( path ).getName(), input );
45 + }
46 + finally {
47 + FileUtil.dispose( input );
48 + }
49 + }
50 + ftp.logout();
51 + ftp.disconnect();
52 + }
53 + catch ( IOException e ) {
54 + throw new WrappedIOException( e );
55 + }
56 + return true;
57 + }
58 + }