KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > coldcore > coloradoftp > command > impl > ftp > MkdCommand


1 /**
2  * Command MKD.
3  * See FTP spec for details on the command.
4  */

5 package com.coldcore.coloradoftp.command.impl.ftp;
6
7 import com.coldcore.coloradoftp.command.Reply;
8 import com.coldcore.coloradoftp.command.impl.AbstractCommand;
9 import com.coldcore.coloradoftp.factory.ObjectFactory;
10 import com.coldcore.coloradoftp.factory.ObjectName;
11 import com.coldcore.coloradoftp.filesystem.FileSystem;
12 import org.apache.log4j.Logger;
13
14 public class MkdCommand extends AbstractCommand {
15
16   private static Logger log = Logger.getLogger(MkdCommand.class);
17
18
19   public Reply execute() {
20     Reply reply = getReply();
21     if (!testLogin()) return reply;
22
23     String JavaDoc dir = getParameter();
24     if (dir.length() == 0) {
25       reply.setCode("501");
26       reply.setText("Send directory name.");
27       return reply;
28     }
29
30     FileSystem fileSystem = (FileSystem) ObjectFactory.getObject(ObjectName.FILESYSTEM);
31     dir = fileSystem.createDirectory(dir, controlConnection.getSession());
32
33     dir = dir.replaceAll("\"", "\"\""); //Encode double-quated
34

35     reply.setCode("257");
36     reply.setText("\""+dir+"\" directory created.");
37     return reply;
38   }
39 }
40
Popular Tags