List of usage examples for org.apache.commons.net.ftp FTPCmd MLSD
FTPCmd MLSD
To view the source code for org.apache.commons.net.ftp FTPCmd MLSD.
Click Source Link
From source file:ch.cyberduck.core.ftp.FTPMlsdListService.java
@Override public AttributedList<Path> list(final Path directory, final ListProgressListener listener) throws BackgroundException { try {// w ww . j a v a 2 s . c o m if (!session.getClient().changeWorkingDirectory(directory.getAbsolute())) { throw new FTPException(session.getClient().getReplyCode(), session.getClient().getReplyString()); } if (!session.getClient().setFileType(FTPClient.ASCII_FILE_TYPE)) { // Set transfer type for traditional data socket file listings. The data transfer is over the // data connection in type ASCII or type EBCDIC. throw new FTPException(session.getClient().getReplyCode(), session.getClient().getReplyString()); } final List<String> list = new FTPDataFallback(session, keychain, prompt) .data(new DataConnectionAction<List<String>>() { @Override public List<String> execute() throws BackgroundException { try { return session.getClient().list(FTPCmd.MLSD); } catch (IOException e) { throw new FTPExceptionMappingService().map(e); } } }, listener); return reader.read(directory, list, listener); } catch (IOException e) { throw new FTPExceptionMappingService().map("Listing directory {0} failed", e, directory); } }
From source file:com.atomicleopard.thundr.ftp.commons.FTP.java
/** * A convenience method to send the FTP MLSD command to the server, * receive the reply, and return the reply code. Remember, it is up * to you to manage the data connection. If you don't need this low * level of access, use {@link org.apache.commons.net.ftp.FTPClient} * , which will handle all low level details for you. * <p>/* ww w. j av a2 s . com*/ * @return The reply code received from the server. * @exception FTPConnectionClosedException * If the FTP server prematurely closes the connection as a result * of the client being idle or some other reason causing the server * to send FTP reply code 421. This exception may be caught either * as an IOException or independently as itself. * @exception IOException If an I/O error occurs while either sending the * command or receiving the server reply. * @since 3.0 */ public int mlsd() throws IOException { return sendCommand(FTPCmd.MLSD); }
From source file:com.atomicleopard.thundr.ftp.commons.FTP.java
/** * A convenience method to send the FTP MLSD command to the server, * receive the reply, and return the reply code. Remember, it is up * to you to manage the data connection. If you don't need this low * level of access, use {@link org.apache.commons.net.ftp.FTPClient} * , which will handle all low level details for you. * <p>/* www . ja v a 2s . c o m*/ * @param path the path to report on * @return The reply code received from the server, * may be {@code null} in which case the command is sent with no parameters * @exception FTPConnectionClosedException * If the FTP server prematurely closes the connection as a result * of the client being idle or some other reason causing the server * to send FTP reply code 421. This exception may be caught either * as an IOException or independently as itself. * @exception IOException If an I/O error occurs while either sending the * command or receiving the server reply. * @since 3.0 */ public int mlsd(String path) throws IOException { return sendCommand(FTPCmd.MLSD, path); }
From source file:com.atomicleopard.thundr.ftp.commons.FTPClient.java
/** * Initiate list parsing for MLSD listings. * * @param pathname// w w w.ja v a 2s .c o m * @return the engine * @throws IOException */ private FTPListParseEngine initiateMListParsing(String pathname) throws IOException { Socket socket = _openDataConnection_(FTPCmd.MLSD, pathname); FTPListParseEngine engine = new FTPListParseEngine(MLSxEntryParser.getInstance()); if (socket == null) { return engine; } try { engine.readServerList(socket.getInputStream(), getControlEncoding()); } finally { Util.closeQuietly(socket); completePendingCommand(); } return engine; }