Subversion Repository Public Repository

litesoft

Diff Revisions 949 vs 950 for /trunk/Java/ScarPlus/src/com/esotericsoftware/scar/FTP.java

Diff revisions: vs.
  @@ -1,72 +1,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 - {
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 + {
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 + }