26 lines
792 B
Java
26 lines
792 B
Java
package com.university.chat.Server;
|
|
|
|
import java.io.IOException;
|
|
import java.nio.file.Files;
|
|
import java.nio.file.Path;
|
|
import java.nio.file.Paths;
|
|
|
|
public class FileManager {
|
|
|
|
private static final String BASE_DIR = "server_data";
|
|
|
|
public static void createUserFolders(String username) throws IOException {
|
|
Path userPath = Paths.get(BASE_DIR, username);
|
|
Files.createDirectories(userPath.resolve("received"));
|
|
Files.createDirectories(userPath.resolve("sent"));
|
|
}
|
|
|
|
public static Path getReceivedPath(String username, String filename) {
|
|
return Paths.get(BASE_DIR, username, "received", filename);
|
|
}
|
|
|
|
public static Path getSentPath(String username, String filename) {
|
|
return Paths.get(BASE_DIR, username, "sent", filename);
|
|
}
|
|
}
|