Project

General

Profile

Statistics
| Revision:

root / src / Protocols / DeleteProtocol.java @ 2

History | View | Annotate | Download (763 Bytes)

1
package Protocols;
2

    
3
import Message.*;
4
import Peers.Peer;
5

    
6
import java.io.File;
7

    
8
public class DeleteProtocol implements Runnable {
9

    
10

    
11
    private final Peer peer;
12
    private final String filepath;
13

    
14
    public DeleteProtocol(Peer peer, String filepath) {
15
        this.peer = peer;
16
        this.filepath = filepath;
17
    }
18

    
19
    @Override
20
    public void run() {
21
        String[] name = filepath.split("/");
22
        String fid = this.peer.getControl().getBackedUpFiles().get(name[name.length - 1]);
23

    
24

    
25
        File n = new File(filepath);
26
        Message ms = new DeleteMsg(peer.getVersionProtocol(), peer.getId(), peer.getControl().getBackedUpFiles().get(name[name.length - 1]));
27

    
28
        peer.getMc_channel().send(ms);
29

    
30
        System.out.println("Deleted");
31
    }
32
}