@ -13,6 +13,7 @@ public class ServerP2P {
public ServerP2P() {
directories = new Directories("P2P_JAVA_PROJECT_SERVER");
directories.createSubdir(subdir);
logger = new Logger(directories.getDataHomeDirectory() + "server.log");
port = 40001;
System.out.println("Server will listen on port " + port + " and serve files from " + directories.getDataHomeDirectory() + subdir);
@ -48,6 +48,20 @@ public class Directories {
new File(dataHomeDirectory).mkdirs();
}
/** Create a subdirectory.
* @param subdir Name of subdirectory to create
*/
public void createSubdir(String subdir) {
String d = dataHomeDirectory;
if (subdir != null) {
d += subdir;
if (!subdir.endsWith("/")) {
d += "/";
new File(d).mkdirs();
/** Getter for dataHomeDirectory.
* @return path to the application home directory