Skip to content

Commit 5585604

Browse files
committed
Add in creating form file at the start of running the app as the tests seems to suggest that it should be there already
1 parent 1297223 commit 5585604

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/main/java/httpserver/App.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,19 @@ public class App {
1414
private static ServerFactory serverFactory;
1515
private static SocketHandlerFactory socketHandlerFactory;
1616
private static PathExaminer pathExaminer;
17+
private static Path root;
1718

1819
public static void main(String[] args) throws IOException {
1920
int port = Integer.parseInt(args[1]);
2021
String fileDirectory = args[3];
2122

2223
pathExaminer = new PathExaminer();
23-
Path root = pathExaminer.getPath(fileDirectory);
24+
root = pathExaminer.getPath(fileDirectory);
2425
Path logPath = pathExaminer.concatenate(root,"logs");
2526
AppConfig appConfig = new AppConfig(root, new Logger(logPath, new FileOperator()));
2627

28+
createFormFile();
29+
2730
serverFactory = new ServerFactory(new ServerSocketFactory(), appConfig);
2831
socketHandlerFactory = new SocketHandlerFactory();
2932

@@ -34,4 +37,12 @@ public static void main(String[] args) throws IOException {
3437
server.acceptConnection(threadPool, socketHandlerFactory);
3538
}
3639
}
40+
41+
private static void createFormFile() {
42+
Path formRoot = pathExaminer.getFullPath(root, "/form");
43+
try {
44+
new FileOperator().createFileAtPath(formRoot);
45+
} catch (IOException e) {
46+
}
47+
}
3748
}

0 commit comments

Comments
 (0)