public ResourceLibrary(String searchName, String scriptName, FileResource resource) { this.searchName = searchName; this.scriptName = scriptName; this.location = resource.absolutePath(); this.resource = resource; }
public ResourceLibrary(String searchName, String scriptName, FileResource resource) { this.searchName = searchName; this.scriptName = scriptName; this.location = resource.absolutePath(); this.resource = resource; }
protected String resolveScriptName(FileResource resource, String ruby18Path) { return resource.absolutePath(); }
protected String resolveLoadName(FileResource resource, String ruby18path) { return resource.absolutePath(); }
protected String resolveLoadName(FileResource resource, String ruby18path) { return resource.absolutePath(); }
protected String resolveScriptName(FileResource resource, String ruby18Path) { return resource.absolutePath(); }
static IOException mapFileNotFoundOnGetChannel(final FileResource file, final FileNotFoundException ex) { // Java throws FileNotFoundException both if the file doesn't exist or there were // permission issues, but Ruby needs to disambiguate those two cases return file.exists() ? new ResourceException.PermissionDenied(file.absolutePath()) : new ResourceException.NotFound(file.absolutePath()); }
static IOException mapFileNotFoundOnGetChannel(final FileResource file, final FileNotFoundException ex) { // Java throws FileNotFoundException both if the file doesn't exist or there were // permission issues, but Ruby needs to disambiguate those two cases return file.exists() ? new ResourceException.PermissionDenied(file.absolutePath()) : new ResourceException.NotFound(file.absolutePath()); }
public static ResourceLibrary create(String searchName, String scriptName, FileResource resource) { String location = resource.absolutePath(); if (location.endsWith(".class")) return new ClassResourceLibrary(searchName, scriptName, resource); if (location.endsWith(".jar")) return new JarResourceLibrary(searchName, scriptName, resource); return new ResourceLibrary(searchName, scriptName, resource); // just .rb? }
public static ResourceLibrary create(String searchName, String scriptName, FileResource resource) { String location = resource.absolutePath(); if (location.endsWith(".class")) return new ClassResourceLibrary(searchName, scriptName, resource); if (location.endsWith(".jar")) return new JarResourceLibrary(searchName, scriptName, resource); return new ResourceLibrary(searchName, scriptName, resource); // just .rb? }
private String resolve(String path, String scriptName) { if (RubyInstanceConfig.DEBUG_SCRIPT_RESOLUTION) { config.getError().println("Trying path: " + path); } try { FileResource fullName = JRubyFile.createRestrictedResource(path, scriptName); if (fullName.exists() && fullName.isFile()) { if (RubyInstanceConfig.DEBUG_SCRIPT_RESOLUTION) { config.getError().println("Found: " + fullName.absolutePath()); } return fullName.absolutePath(); } } catch (Exception e) { // keep going } return null; }
private String resolve(String path, String scriptName) { if (RubyInstanceConfig.DEBUG_SCRIPT_RESOLUTION) { config.getError().println("Trying path: " + path); } try { FileResource fullName = JRubyFile.createRestrictedResource(path, scriptName); if (fullName.exists() && fullName.isFile()) { if (RubyInstanceConfig.DEBUG_SCRIPT_RESOLUTION) { config.getError().println("Found: " + fullName.absolutePath()); } return fullName.absolutePath(); } } catch (Exception e) { // keep going } return null; }
@JRubyMethod(name = "birthtime") public IRubyObject birthtime() { checkInitialized(); FileTime btime = null; if (file == null || (btime = RubyFile.getBirthtimeWithNIO(file.absolutePath())) == null) { return ctime(); } return getRuntime().newTime(btime.toMillis()); }
@JRubyMethod(name = "birthtime") public IRubyObject birthtime() { checkInitialized(); FileTime btime = null; if (file == null || (btime = RubyFile.getBirthtimeWithNIO(file.absolutePath())) == null) { return ctime(); } return getRuntime().newTime(btime.toMillis()); }
private static RubyFileStat getRubyFileStat(ThreadContext context, IRubyObject filename) { Ruby runtime = context.runtime; RubyFileStat stat = null; if (!(filename instanceof RubyFile)) { RubyString path = get_path(context, filename); FileResource file = JRubyFile.createResource(runtime, path.getUnicodeValue()); if (file.exists()) { stat = runtime.newFileStat(file.absolutePath(), false); } } else { stat = (RubyFileStat) ((RubyFile) filename).stat(context); } return stat; }
private static RubyFileStat getRubyFileStat(ThreadContext context, IRubyObject filename) { Ruby runtime = context.runtime; RubyFileStat stat = null; if (!(filename instanceof RubyFile)) { RubyString path = get_path(context, filename); FileResource file = JRubyFile.createResource(runtime, path.getUnicodeValue()); if (file.exists()) { stat = runtime.newFileStat(file.absolutePath(), false); } } else { stat = (RubyFileStat) ((RubyFile) filename).stat(context); } return stat; }
public static IRubyObject mkfifo(ThreadContext context, RubyString path, int mode) { Ruby runtime = context.runtime; String decodedPath = JRubyFile.createResource(runtime, path.toString()).absolutePath(); if (runtime.getPosix().mkfifo(decodedPath, mode) != 0) { throw runtime.newErrnoFromInt(runtime.getPosix().errno(), decodedPath); } return RubyFixnum.zero(runtime); }
private static RubyFileStat getFileStat(ThreadContext context, IRubyObject filename) { Ruby runtime = context.runtime; RubyFileStat stat = null; if (!(filename instanceof RubyFile)) { RubyString path = get_path(context, filename); FileResource file = JRubyFile.createResource(runtime.getCurrentDirectory(), path.getUnicodeValue()); if (file.exists()) { stat = runtime.newFileStat(file.absolutePath(), false); } } else { stat = (RubyFileStat) ((RubyFile) filename).stat(context); } return stat; }
public static IRubyObject mkfifo(ThreadContext context, RubyString path, int mode) { Ruby runtime = context.runtime; String decodedPath = JRubyFile.createResource(runtime, path.toString()).absolutePath(); if (runtime.getPosix().mkfifo(decodedPath, mode) != 0) { throw runtime.newErrnoFromInt(runtime.getPosix().errno(), decodedPath); } return RubyFixnum.zero(runtime); }
private FoundLibrary findFileResourceWithLoadPath(String searchName, String suffix, String loadPath) { String fullPath = loadPath != null ? loadPath + "/" + searchName : searchName; String pathWithSuffix = fullPath + suffix; DebugLog.Resource.logTry(pathWithSuffix); FileResource resource = JRubyFile.createResourceAsFile(runtime, pathWithSuffix); if (resource.exists()) { if (resource.absolutePath() != resource.canonicalPath()) { FileResource expandedResource = JRubyFile.createResourceAsFile(runtime, resource.canonicalPath()); if (expandedResource.exists()){ String scriptName = resolveScriptName(expandedResource, expandedResource.canonicalPath()); String loadName = resolveLoadName(expandedResource, searchName + suffix); return new FoundLibrary(ResourceLibrary.create(searchName, scriptName, resource), loadName); } } DebugLog.Resource.logFound(pathWithSuffix); String scriptName = resolveScriptName(resource, pathWithSuffix); String loadName = resolveLoadName(resource, searchName + suffix); return new FoundLibrary(ResourceLibrary.create(searchName, scriptName, resource), loadName); } return null; }