LoadServiceResource foundResource = null;
try {
if (!Ruby.isSecurityRestricted()) {
String reportedPath = loadPathEntry + "/" + namePlusSuffix;
JRubyFile actualPath;
// we check length == 0 for 'load', which does not use load path
if (new File(reportedPath).isAbsolute()) {
// it's an absolute path, use it as-is
actualPath = JRubyFile.create(loadPathEntry, RubyFile.expandUserPath(runtime.getCurrentContext(), namePlusSuffix));
} else {
// prepend ./ if . is not already there, since we're loading based on CWD
if (reportedPath.charAt(0) != '.') {
reportedPath = "./" + reportedPath;
}
actualPath = JRubyFile.create(JRubyFile.create(runtime.getCurrentDirectory(), loadPathEntry).getAbsolutePath(), RubyFile.expandUserPath(runtime.getCurrentContext(), namePlusSuffix));
}
if (actualPath.isFile()) {
try {
foundResource = new LoadServiceResource(actualPath.toURI().toURL(), reportedPath);
} catch (MalformedURLException e) {
throw runtime.newIOErrorFromException(e);
}
}
}