Skip to content

Commit

Permalink
[1.20.4] [All] Exception when removing duplicates modules on windows (#…
Browse files Browse the repository at this point in the history
…25)

* handle windows filepaths correctly

* sanitize the file separators on the BaseFileAccess

* fix: paths converted to system path

* removed changes on unused files

* removed intellij indentation
  • Loading branch information
Edouard127 authored Dec 12, 2024
1 parent b79d342 commit 0882bb6
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,10 @@ private static void removeDuplicates(List<String> cpList, List<Map.Entry<Path, P
Set<String> modules = new HashSet<>();
og.handle(path -> {
if (path.endsWith(".class")) {
String sanitized = path.replace(File.separatorChar, '/');

// Get package name, i.e. "dev/architectury/transformer/TransformerRuntime.class" -> "dev.architectury.transformer"
String packageName = Transform.trimLeadingSlash(path).substring(0, Transform.trimLeadingSlash(path).lastIndexOf('/')).replace('/', '.');
String packageName = Transform.trimLeadingSlash(sanitized).substring(0, Transform.trimLeadingSlash(sanitized).lastIndexOf('/')).replace('/', '.');
modules.add(packageName);
}
});
Expand All @@ -244,7 +246,7 @@ private static void removeDuplicates(List<String> cpList, List<Map.Entry<Path, P
try (OpenedFileAccess ac = OpenedFileAccess.ofDirectory(cpPath)) {
Set<String> modules = new HashSet<>();
ac.handle(path -> {
String relative = Transform.trimLeadingSlash(cpPath.relativize(Paths.get(path)).toString());
String relative = Transform.trimLeadingSlash(cpPath.relativize(Paths.get(path)).toString().replace(File.separatorChar, '/'));
if (relative.endsWith(".class")) {
// Get package name, i.e. "dev/architectury/transformer/TransformerRuntime.class" -> "dev.architectury.transformer"
String packageName = relative.substring(0, relative.lastIndexOf('/')).replace('/', '.');
Expand Down

0 comments on commit 0882bb6

Please sign in to comment.