public void execute()

in core/src/main/java/org/apache/ftpserver/command/impl/STAT.java [58:108]


    public void execute(final FtpIoSession session,
            final FtpServerContext context, final FtpRequest request)
            throws IOException {

        // reset state variables
        session.resetState();

        if(request.getArgument() != null) {
            ListArgument parsedArg = ListArgumentParser.parse(request.getArgument());

            // check that the directory or file exists
            FtpFile file = null;
            try {
                file = session.getFileSystemView().getFile(parsedArg.getFile());
                if(!file.doesExist()) {
                    session.write(LocalizedDataTransferFtpReply.translate(session, request, context,
                            FtpReply.REPLY_450_REQUESTED_FILE_ACTION_NOT_TAKEN, "LIST",
                            null, file));             
                    return;
                }
                
                String dirList = directoryLister.listFiles(parsedArg, 
                        session.getFileSystemView(), LIST_FILE_FORMATER);

                int replyCode;
                if(file.isDirectory()) {
                    replyCode = FtpReply.REPLY_212_DIRECTORY_STATUS;
                } else {
                    replyCode = FtpReply.REPLY_213_FILE_STATUS;
                }
                
                session.write(LocalizedFileActionFtpReply.translate(session, request, context,
                        replyCode, "STAT", dirList, file));
                
            } catch (FtpException e) {
                session
                .write(LocalizedFileActionFtpReply
                        .translate(
                                session,
                                request,
                                context,
                                FtpReply.REPLY_450_REQUESTED_FILE_ACTION_NOT_TAKEN,
                                "STAT", null, file));
            }
        
        } else {
            // write the status info
            session.write(LocalizedFtpReply.translate(session, request, context,
                    FtpReply.REPLY_211_SYSTEM_STATUS_REPLY, "STAT", null));
        }
    }