From 3a27d84690b81efd2b168417478969c39da99f62 Mon Sep 17 00:00:00 2001 From: Louis Date: Tue, 21 Jan 2020 11:32:01 +0100 Subject: [PATCH] Add openning functionnality to server --- src/serverP2P/ServerP2P.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/serverP2P/ServerP2P.java b/src/serverP2P/ServerP2P.java index 18c11f4..601c54e 100644 --- a/src/serverP2P/ServerP2P.java +++ b/src/serverP2P/ServerP2P.java @@ -1,14 +1,27 @@ package serverP2P; import serverP2P.ServerManagementUDP; import tools.Directories; +import java.util.Scanner; public class ServerP2P { private int port; private String dataHomeDirectory; public ServerP2P() { + Directories d = new Directories("P2P_JAVA_PROJECT_SERVER"); + String os = System.getProperty("os.name"); + port = 40000; - dataHomeDirectory = new Directories("P2P_JAVA_PROJECT_SERVER").getDataHomeDirectory(); + dataHomeDirectory = d.getDataHomeDirectory(); System.out.println("Server will listen on port " + port + " and serve files from " + dataHomeDirectory); + if (os.equals("Linux")||os.equals("Mac")||os.equals("Mac OS X")) { + System.out.println("Do you want to open this directory? (y/N)"); + Scanner scanner = new Scanner(System.in); + String resp = scanner.nextLine(); + if (resp.equals("y") || resp.equals("Y")) { + System.out.println("Openning"); + d.openDataHomeDirectory(); + } + } } public static void main(String [] args) { ServerP2P s = new ServerP2P();