11
11
12
12
import java .io .File ;
13
13
import java .io .IOException ;
14
- import java .util .Locale ;
15
14
16
15
import com .oracle .truffle .api .nodes .Node ;
17
16
import org .graalvm .collections .Pair ;
@@ -57,7 +56,6 @@ public static void ensureReadable(RubyContext context, TruffleFile file, Node cu
57
56
}
58
57
}
59
58
60
-
61
59
public Pair <Source , TStringWithEncoding > loadFile (String path ) throws IOException {
62
60
if (context .getOptions ().LOG_LOAD ) {
63
61
RubyLanguage .LOGGER .info ("loading " + path );
@@ -93,7 +91,7 @@ public static TruffleFile getSafeTruffleFile(RubyLanguage language, RubyContext
93
91
}
94
92
95
93
final TruffleFile home = language .getRubyHomeTruffleFile ();
96
- if (file .startsWith (home ) && isStdLibRubyOrCExtFile (home . relativize ( file ))) {
94
+ if (file .startsWith (home . resolve ( "lib" )) && isStdLibRubyOrCExtFile (file . getPath ( ))) {
97
95
return file ;
98
96
} else {
99
97
try {
@@ -109,19 +107,8 @@ public static TruffleFile getSafeTruffleFile(RubyLanguage language, RubyContext
109
107
}
110
108
}
111
109
112
- private static boolean isStdLibRubyOrCExtFile (TruffleFile relativePathFromHome ) {
113
- final String fileName = relativePathFromHome .getName ();
114
- if (fileName == null ) {
115
- return false ;
116
- }
117
-
118
- final String lowerCaseFileName = fileName .toLowerCase (Locale .ROOT );
119
- if (!lowerCaseFileName .endsWith (TruffleRuby .EXTENSION ) &&
120
- !lowerCaseFileName .endsWith (RubyLanguage .CEXT_EXTENSION )) {
121
- return false ;
122
- }
123
-
124
- return relativePathFromHome .startsWith ("lib" );
110
+ private static boolean isStdLibRubyOrCExtFile (String path ) {
111
+ return path .endsWith (TruffleRuby .EXTENSION ) || path .endsWith (RubyLanguage .CEXT_EXTENSION );
125
112
}
126
113
127
114
Source buildSource (TruffleFile file , String path , TStringWithEncoding sourceTStringWithEncoding , boolean internal ,
0 commit comments