Skip to content

Commit 983637f

Browse files
Duplicate definition: Case-insensitive FS on Windows and MacOS
1 parent cf1fa2f commit 983637f

File tree

1 file changed

+23
-1
lines changed
  • core/esmf-aspect-meta-model-java/src/main/java/org/eclipse/esmf/aspectmodel/resolver/fs

1 file changed

+23
-1
lines changed

core/esmf-aspect-meta-model-java/src/main/java/org/eclipse/esmf/aspectmodel/resolver/fs/ModelsRoot.java

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,23 @@
1414
package org.eclipse.esmf.aspectmodel.resolver.fs;
1515

1616
import java.io.File;
17+
import java.io.IOException;
1718
import java.net.URI;
1819
import java.nio.file.Path;
1920
import java.nio.file.Paths;
21+
import java.util.Objects;
2022
import java.util.stream.Stream;
2123

2224
import org.eclipse.esmf.aspectmodel.urn.AspectModelUrn;
2325

26+
import org.slf4j.Logger;
27+
import org.slf4j.LoggerFactory;
28+
29+
2430
public abstract class ModelsRoot {
31+
32+
private static final Logger LOG = LoggerFactory.getLogger( ModelsRoot.class );
33+
private static final File EMPTY_FILE = new File( "" );
2534
private final Path root;
2635

2736
protected ModelsRoot( final Path root ) {
@@ -43,6 +52,19 @@ public Stream<Path> paths() {
4352
public abstract Path directoryForNamespace( final AspectModelUrn urn );
4453

4554
public File determineAspectModelFile( final AspectModelUrn urn ) {
46-
return directoryForNamespace( urn ).resolve( urn.getName() + ".ttl" ).toFile();
55+
Path path = directoryForNamespace( urn ).resolve( urn.getName() + ".ttl" );
56+
return resolveByCanonicalPath( path );
57+
}
58+
59+
private static File resolveByCanonicalPath( Path path ) {
60+
File file = path.toFile();
61+
try {
62+
if ( Objects.equals( path.toString(), file.getCanonicalPath() ) ) {
63+
return file;
64+
}
65+
} catch ( IOException exception ) {
66+
LOG.error( "Error resolving canonical path for file: {}", file.getPath(), exception );
67+
}
68+
return EMPTY_FILE;
4769
}
4870
}

0 commit comments

Comments
 (0)