Canonicalized file paths in modListFile handling with the minecraftDirectory.

This commit is contained in:
cpw 2014-08-31 14:14:15 -04:00
parent f5cf87304b
commit a04c3e12fe
2 changed files with 17 additions and 12 deletions

View file

@ -217,7 +217,7 @@ public class CoreModManager {
private static void discoverCoreMods(File mcDir, LaunchClassLoader classLoader)
{
ModListHelper.parseModList();
ModListHelper.parseModList(mcDir);
FMLRelaunchLog.fine("Discovering coremods");
File coreMods = setupCoreModDir(mcDir);
FilenameFilter ff = new FilenameFilter() {

View file

@ -2,34 +2,31 @@ package cpw.mods.fml.relauncher;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import net.minecraft.launchwrapper.Launch;
import org.apache.logging.log4j.Level;
import com.google.common.base.Charsets;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.google.common.io.Files;
import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;
import net.minecraft.launchwrapper.Launch;
public class ModListHelper {
public static class JsonModList {
public String repositoryRoot;
public List<String> modRef;
public String parentList;
}
private static File mcDirectory;
private static Set<File> visitedFiles = Sets.newHashSet();
public static final Map<String,File> additionalMods = Maps.newLinkedHashMap();
static void parseModList()
static void parseModList(File minecraftDirectory)
{
FMLRelaunchLog.fine("Attempting to load commandline specified mods");
FMLRelaunchLog.fine("Attempting to load commandline specified mods, relative to %s", minecraftDirectory.getAbsolutePath());
mcDirectory = minecraftDirectory;
@SuppressWarnings("unchecked")
Map<String,String> args = (Map<String, String>) Launch.blackboard.get("launchArgs");
String listFile = args.get("--modListFile");
@ -48,10 +45,18 @@ public class ModListHelper {
}
}
private static void parseListFile(String listFile) {
File f = new File(listFile);
File f;
try
{
f = new File(mcDirectory, listFile).getCanonicalFile();
} catch (IOException e2)
{
FMLRelaunchLog.log(Level.INFO, e2, "Unable to canonicalize path %s relative to %s", listFile, mcDirectory.getAbsolutePath());
return;
}
if (!f.exists())
{
FMLRelaunchLog.info("Failed to find modList file %s", listFile);
FMLRelaunchLog.info("Failed to find modList file %s", f.getAbsolutePath());
return;
}
if (visitedFiles.contains(f))
@ -109,7 +114,7 @@ public class ModListHelper {
}
}
private static void tryAddFile(String modFileName, File repoRoot, String descriptor) {
File modFile = repoRoot != null ? new File(repoRoot,modFileName) : new File(modFileName);
File modFile = repoRoot != null ? new File(repoRoot,modFileName) : new File(mcDirectory, modFileName);
if (!modFile.exists())
{
FMLRelaunchLog.info("Failed to find mod file %s (%s)", descriptor, modFile.getAbsolutePath());