Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 1 addition & 14 deletions MekWarsClient/src/mekwars/client/io/FileSystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,13 @@

package mekwars.client.io;

import java.io.IOException;
import java.lang.IllegalArgumentException;
import java.nio.file.FileSystems;
import java.nio.file.Path;
import mekwars.common.campaign.clientutils.IClientConfig;
import mekwars.common.util.IOUtil;
import mekwars.common.io.FileChecksum;
import mekwars.common.io.AbstractFileSystem;

public class FileSystem extends AbstractFileSystem {
private Path configDir;
private Path campaignConfig;

private static final String DIRECTORY_NAME_SERVERS = DIRECTORY_NAME_DATA + "servers/";
private static final Path DIRECTORY_SERVERS = FileSystems.getDefault()
Expand Down Expand Up @@ -64,7 +59,6 @@ public Path getDataLastUpdated() {
*/
public void setConfigDir(String configDir) {
this.configDir = FileSystems.getDefault().getPath(configDir);
this.campaignConfig = FileSystems.getDefault().getPath(configDir, FILE_NAME_CAMPAIGN_CONFIG);
}

/**
Expand All @@ -89,20 +83,13 @@ public void setConfigDir(IClientConfig config) throws Exception {

String configDirName = DIRECTORY_NAME_SERVERS + serverIp + "." + serverPort;
this.configDir = FileSystems.getDefault().getPath(configDirName);
this.campaignConfig = FileSystems.getDefault().getPath(
configDir.getFileName().toString(),
config.getParam("CAMPAIGNCONFIG")
);
calculateChecksums();
}

public Path getConfigDir() {
return configDir;
}

public Path getCampaignConfig() {
return campaignConfig;
}

public Path[] getDirectories() {
return DIRECTORIES;
}
Expand Down
5 changes: 4 additions & 1 deletion MekWarsCommon/src/mekwars/common/io/AbstractFileSystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ public Path getOpList() {
*
* @return The path to the campaignconfig.txt file.
*/
public abstract Path getCampaignConfig();
public Path getCampaignConfig() {
return FileSystems.getDefault().getPath(getConfigDir().toString(), FILE_NAME_CAMPAIGN_CONFIG);
}

/**
* Returns The path to the directory that contains all shared configurations.
Expand Down Expand Up @@ -127,6 +129,7 @@ public ConcurrentHashMap<String, FileChecksum> getChecksumFiles() {
* @throws IOException If there is an error in reading one of the files.
*/
public void calculateChecksums() throws IOException {
checksumHash.clear();
for (Path path : getConfigFiles()) {
if (getFile(path.getFileName().toString()) == null && Files.exists(path)) {
FileChecksum fileChecksum = new FileChecksum(path);
Expand Down
1 change: 1 addition & 0 deletions MekWarsServer/src/mekwars/server/io/FileSystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ public static Path getOperationsLongDir() {
return DIRECTORY_OPERATIONS_LONG;
}

@Override
public Path getCampaignConfig() {
return FileSystems.getDefault().getPath(
getConfigDir().toString(),
Expand Down