Browse Source

Major changes

Added folder creation
master
Sogomn 9 years ago
parent
commit
b4f20ec7c6
  1. 48
      Ratty/src/de/sogomn/rat/packet/NewFolderPacket.java
  2. 3
      Ratty/src/de/sogomn/rat/packet/PacketType.java
  3. 12
      Ratty/src/de/sogomn/rat/server/gui/RattyGuiController.java

48
Ratty/src/de/sogomn/rat/packet/NewFolderPacket.java

@ -0,0 +1,48 @@
package de.sogomn.rat.packet;
import java.io.File;
import de.sogomn.engine.util.FileUtils;
import de.sogomn.rat.ActiveClient;
public final class NewFolderPacket implements IPacket {
private String path, name;
public NewFolderPacket(final String path, final String name) {
this.path = path;
this.name = name;
}
public NewFolderPacket() {
this("", "");
}
@Override
public void send(final ActiveClient client) {
client.writeUTF(path);
client.writeUTF(name);
}
@Override
public void receive(final ActiveClient client) {
path = client.readUTF();
name = client.readUTF();
}
@Override
public void execute(final ActiveClient client) {
final String fullPath = path + File.separator + name;
FileUtils.createFolder(fullPath);
}
public String getPath() {
return path;
}
public String getName() {
return name;
}
}

3
Ratty/src/de/sogomn/rat/packet/PacketType.java

@ -14,7 +14,8 @@ public enum PacketType {
FILE(9, FileSystemPacket.class),
DOWNLOAD(10, DownloadPacket.class),
UPLOAD(11, UploadPacket.class),
EXECUTE(12, ExecutePacket.class);
EXECUTE(12, ExecutePacket.class),
FOLDER(13, NewFolderPacket.class);
public final byte id;
public final Class<? extends IPacket> clazz;

12
Ratty/src/de/sogomn/rat/server/gui/RattyGuiController.java

@ -5,6 +5,7 @@ import java.io.File;
import java.util.ArrayList;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import de.sogomn.rat.ActiveClient;
import de.sogomn.rat.IClientObserver;
@ -17,6 +18,7 @@ import de.sogomn.rat.packet.FileSystemPacket;
import de.sogomn.rat.packet.FreePacket;
import de.sogomn.rat.packet.IPacket;
import de.sogomn.rat.packet.InformationPacket;
import de.sogomn.rat.packet.NewFolderPacket;
import de.sogomn.rat.packet.PopupPacket;
import de.sogomn.rat.packet.ScreenshotPacket;
import de.sogomn.rat.packet.UploadPacket;
@ -115,6 +117,16 @@ public final class RattyGuiController implements IServerObserver, IClientObserve
final ExecutePacket packet = new ExecutePacket(path);
return packet;
} else if (command == FileTreePanel.NEW_FOLDER) {
final FileTreePanel treePanel = serverClient.getTreePanel();
final String path = treePanel.getLastNodeClickedFolder();
final String name = JOptionPane.showInputDialog(null);
if (name != null && !name.isEmpty()) {
final NewFolderPacket packet = new NewFolderPacket(path, name);
return packet;
}
}
return null;

Loading…
Cancel
Save