Skip to content

Commit

Permalink
Fix Windows backslash in URI
Browse files Browse the repository at this point in the history
  • Loading branch information
roccodev committed Oct 19, 2019
1 parent a76eb01 commit b77f5f7
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 5 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ yarn_mappings=1.14.4+build.12
loader_version=0.6.3+build.167

# Mod Properties
mod_version = 1.0.0
mod_version = 1.0.1
maven_group = eu.5zigreborn
archives_base_name = 5zig-Fabric-Installer

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public void run() {
}

private static void removeMixinLib(File file) throws IOException {
URI uri = URI.create("jar:file:" + file.getAbsolutePath());
URI uri = URI.create("jar:file:" + FileLocator.getAbsolutePath(file));

try (FileSystem zipfs = FileSystems.newFileSystem(uri, new HashMap<>())) {
Path pathInZipfile = zipfs.getPath("org/spongepowered");
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/eu/the5zig/fabric/remap/MixinRemapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import eu.the5zig.fabric.util.FileLocator;
import eu.the5zig.fabric.util.MethodUtils;
import net.fabricmc.loader.api.FabricLoader;
import net.fabricmc.tinyremapper.IMappingProvider;
Expand Down Expand Up @@ -105,7 +106,7 @@ public void setNewFile(File newFile) {
}

public void write() throws IOException {
URI uri = URI.create("jar:file:" + newFile.getAbsolutePath());
URI uri = URI.create("jar:file:" + FileLocator.getAbsolutePath(newFile));

try (FileSystem zipfs = FileSystems.newFileSystem(uri, new HashMap<>())) {
Path pathInZipfile = zipfs.getPath("mixins.refmap.json");
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/eu/the5zig/fabric/remap/MixinShadowPatch.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

package eu.the5zig.fabric.remap;

import eu.the5zig.fabric.util.FileLocator;
import eu.the5zig.fabric.util.MethodUtils;
import org.objectweb.asm.*;
import org.objectweb.asm.commons.ClassRemapper;
Expand All @@ -41,7 +42,7 @@ public class MixinShadowPatch {

public static void patchMixins(File source) throws IOException {
ZipFile file = new ZipFile(source);
URI uri = URI.create("jar:file:" + source.getAbsolutePath());
URI uri = URI.create("jar:file:" + FileLocator.getAbsolutePath(source));
Enumeration<? extends ZipEntry> elems = file.entries();
while (elems.hasMoreElements()) {
ZipEntry entry = elems.nextElement();
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/eu/the5zig/fabric/util/FileLocator.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import net.fabricmc.loader.launch.common.FabricLauncherBase;
import net.fabricmc.loader.util.UrlConversionException;
import net.fabricmc.loader.util.UrlUtil;
import org.apache.commons.lang3.SystemUtils;

import java.io.File;
import java.io.IOException;
Expand Down Expand Up @@ -59,4 +60,12 @@ public static List<Path> getLibs() {
}
}).filter(Files::exists).collect(Collectors.toList());
}

public static String getAbsolutePath(File file) {
String path = file.getAbsolutePath();
if(SystemUtils.IS_OS_WINDOWS) {
path = path.replace("\\", "/");
}
return path;
}
}
2 changes: 1 addition & 1 deletion src/main/java/eu/the5zig/fabric/util/ModManifest.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public static void injectManifest(String version, File file) throws IOException
String data = IOUtils.toString(ModManifest.class.getResourceAsStream("/out.mod.json"), "UTF-8");
JsonObject json = new JsonParser().parse(data).getAsJsonObject();
json.addProperty("version", version);
URI uri = URI.create("jar:file:" + file.getAbsolutePath());
URI uri = URI.create("jar:file:" + FileLocator.getAbsolutePath(file));

try (FileSystem zipfs = FileSystems.newFileSystem(uri, new HashMap<>())) {
Path pathInZipfile = zipfs.getPath("fabric.mod.json");
Expand Down

0 comments on commit b77f5f7

Please sign in to comment.