Index: conf/ftpcommands.conf.dist =================================================================== --- conf/ftpcommands.conf.dist (revision 1638) +++ conf/ftpcommands.conf.dist (working copy) @@ -22,3 +22,5 @@ USER=org.drftpd.commands.login.LoginHandler.doUSER PASS=org.drftpd.commands.login.LoginHandler.doPASS QUIT=org.drftpd.commands.login.LoginHandler.doQUIT + +LIST=org.drftpd.commands.list.LIST.doLIST Index: src/master/src/org/drftpd/master/CommitManager.java =================================================================== --- src/master/src/org/drftpd/master/CommitManager.java (revision 1638) +++ src/master/src/org/drftpd/master/CommitManager.java (working copy) @@ -32,6 +32,7 @@ import org.java.plugin.PluginManager; /** + * @author zubov * @version $Id$ */ public class CommitManager { Index: src/master/src/org/drftpd/commands/LIST.java =================================================================== --- src/master/src/org/drftpd/commands/LIST.java (revision 1638) +++ src/master/src/org/drftpd/commands/LIST.java (working copy) @@ -1,422 +0,0 @@ -/* - * This file is part of DrFTPD, Distributed FTP Daemon. - * - * DrFTPD is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * DrFTPD is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with DrFTPD; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -package org.drftpd.commands; - -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.OutputStreamWriter; -import java.io.PrintWriter; -import java.io.Writer; -import java.net.Socket; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Calendar; -import java.util.Collection; -import java.util.Date; -import java.util.GregorianCalendar; -import java.util.Iterator; -import java.util.List; -import java.util.StringTokenizer; - - -import org.apache.log4j.Logger; -import org.drftpd.commandmanager.CommandHandler; -import org.drftpd.commandmanager.CommandHandlerFactory; -import org.drftpd.commandmanager.CommandManager; -import org.drftpd.commandmanager.CommandManagerFactory; -import org.drftpd.commandmanager.Reply; -import org.drftpd.master.BaseFtpConnection; -import org.drftpd.master.TransferState; -import org.drftpd.util.FtpRequest; -import org.drftpd.vfs.DirectoryHandle; -import org.drftpd.vfs.FileHandle; -import org.drftpd.vfs.InodeHandleInterface; -import org.drftpd.vfs.LinkHandle; -import org.drftpd.vfs.ListUtils; -import org.drftpd.vfs.ObjectNotValidException; - -/** - * @author mog - * - * @version $Id$ - */ -public class LIST implements CommandHandler, CommandHandlerFactory { - private final static DateFormat AFTER_SIX = new SimpleDateFormat(" yyyy"); - - private final static DateFormat BEFORE_SIX = new SimpleDateFormat("HH:mm"); - - private final static String DELIM = " "; - - private final static DateFormat FULL = new SimpleDateFormat("HH:mm:ss yyyy"); - - private static final Logger logger = Logger.getLogger(LIST.class); - - private final static String[] MONTHS = { "Jan", "Feb", "Mar", "Apr", "May", - "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; - - private final static String NEWLINE = "\r\n"; - - /* */ - - /** - * Get file name. - */ - - /* - * private static String getName(LinkedRemoteFileInterface fl) { String - * flName = fl.getName(); - * - * int lastIndex = flName.lastIndexOf("/"); - * - * if (lastIndex == -1) { return flName; } else { return - * flName.substring(lastIndex + 1); } } - */ - - /** - * Get permission string. - */ - private static String getPermission(InodeHandleInterface fl) - throws FileNotFoundException { - StringBuffer sb = new StringBuffer(13); - - if (fl.isLink()) { - sb.append("l"); - } else if (fl.isDirectory()) { - sb.append("d"); - } else { - sb.append("-"); - } - sb.append("rw"); - sb.append(fl.isDirectory() ? "x" : "-"); - - sb.append("rw"); - sb.append(fl.isDirectory() ? "x" : "-"); - - sb.append("rw"); - sb.append(fl.isDirectory() ? "x" : "-"); - - return sb.toString(); - } - - public static String getUnixDate(long date, boolean fulldate) { - Date date1 = new Date(date); - long dateTime = date1.getTime(); - - if (dateTime < 0) { - return "------------"; - } - - Calendar cal = new GregorianCalendar(); - cal.setTime(date1); - - String firstPart = MONTHS[cal.get(Calendar.MONTH)] + ' '; - - String dateStr = String.valueOf(cal.get(Calendar.DATE)); - - if (dateStr.length() == 1) { - dateStr = ' ' + dateStr; - } - - firstPart += (dateStr + ' '); - - long nowTime = System.currentTimeMillis(); - - if (fulldate) { - return firstPart + FULL.format(date1); - } else if (Math.abs(nowTime - dateTime) > (183L * 24L * 60L * 60L * 1000L)) { - return firstPart + AFTER_SIX.format(date1); - } else { - return firstPart + BEFORE_SIX.format(date1); - } - } - - /** - * Get each directory line. - */ - private static void printLine(InodeHandleInterface fl, Writer out, - boolean fulldate) throws IOException { - StringBuffer line = new StringBuffer(); - - if (fl instanceof FileHandle - && !((FileHandle) fl).isAvailable()) { - line.append("----------"); - } else { - line.append(getPermission(fl)); - } - - line.append(DELIM); - line.append((fl.isDirectory() ? "3" : "1")); - line.append(DELIM); - line.append(ListUtils.padToLength(fl.getUsername(), 8)); - line.append(DELIM); - line.append(ListUtils.padToLength(fl.getGroup(), 8)); - line.append(DELIM); - line.append(fl.getSize()); - line.append(DELIM); - line.append(getUnixDate(fl.lastModified(), fulldate)); - line.append(DELIM); - line.append(fl.getName()); - if (fl.isLink()) { - line.append(DELIM + "->" + DELIM + ((LinkHandle)fl).getTargetString()); - } - line.append(NEWLINE); - out.write(line.toString()); - } - - /** - * Print file list. Detail listing. - * - *
- * -a : display all (including hidden files) - *- * - * @return true if success - */ - private static void printList(Collection
- * -l : detail listing - * -a : display all (including hidden files) - *- * - * @return true if success - */ - private static void printNList(Collection
NLST [<SP> <pathname>] <CRLF>LIST [<SP> <pathname>] <CRLF>STAT [<SP> <pathname>] <CRLF>