@Deprecated default JRubyFile hackyGetJRubyFile() { try { return unwrap(JRubyFile.class); } catch (UnsupportedOperationException ex) { return JRubyFile.DUMMY; } }
@Deprecated default JRubyFile hackyGetJRubyFile() { try { return unwrap(JRubyFile.class); } catch (UnsupportedOperationException ex) { return JRubyFile.DUMMY; } }
@Deprecated // Use fileResource instead public static JRubyFile file(IRubyObject pathOrFile) { return fileResource(pathOrFile).unwrap(JRubyFile.class); }
@Deprecated // Use fileResource instead public static JRubyFile file(IRubyObject pathOrFile) { return fileResource(pathOrFile).unwrap(JRubyFile.class); }
private static IRubyObject mkdirCommon(Ruby runtime, String path, IRubyObject[] args) { if (path.startsWith("uri:")) throw runtime.newErrnoEACCESError(path); path = dirFromPath(path, runtime); FileResource res = JRubyFile.createResource(runtime, path); if (res.isDirectory()) throw runtime.newErrnoEEXISTError(path); String name = path.replace('\\', '/'); boolean startsWithDriveLetterOnWindows = RubyFile.startsWithDriveLetterOnWindows(name); // don't attempt to create a dir for drive letters if (startsWithDriveLetterOnWindows) { // path is just drive letter plus : if (path.length() == 2) return RubyFixnum.zero(runtime); // path is drive letter plus : plus leading or trailing / if (path.length() == 3 && (path.charAt(0) == '/' || path.charAt(2) == '/')) return RubyFixnum.zero(runtime); // path is drive letter plus : plus leading and trailing / if (path.length() == 4 && (path.charAt(0) == '/' && path.charAt(3) == '/')) return RubyFixnum.zero(runtime); } File newDir = res.unwrap(File.class); if (File.separatorChar == '\\') newDir = new File(newDir.getPath()); int mode = args.length == 2 ? ((int) args[1].convertToInteger().getLongValue()) : 0777; if (runtime.getPosix().mkdir(newDir.getAbsolutePath(), mode) < 0) { // FIXME: This is a system error based on errno throw runtime.newSystemCallError("mkdir failed"); } return RubyFixnum.zero(runtime); }
private static IRubyObject mkdirCommon(Ruby runtime, String path, IRubyObject[] args) { if (path.startsWith("uri:")) throw runtime.newErrnoEACCESError(path); path = dirFromPath(path, runtime); FileResource res = JRubyFile.createResource(runtime, path); if (res.isDirectory()) throw runtime.newErrnoEEXISTError(path); String name = path.replace('\\', '/'); boolean startsWithDriveLetterOnWindows = RubyFile.startsWithDriveLetterOnWindows(name); // don't attempt to create a dir for drive letters if (startsWithDriveLetterOnWindows) { // path is just drive letter plus : if (path.length() == 2) return RubyFixnum.zero(runtime); // path is drive letter plus : plus leading or trailing / if (path.length() == 3 && (path.charAt(0) == '/' || path.charAt(2) == '/')) return RubyFixnum.zero(runtime); // path is drive letter plus : plus leading and trailing / if (path.length() == 4 && (path.charAt(0) == '/' && path.charAt(3) == '/')) return RubyFixnum.zero(runtime); } File newDir = res.unwrap(File.class); if (File.separatorChar == '\\') newDir = new File(newDir.getPath()); int mode = args.length == 2 ? ((int) args[1].convertToInteger().getLongValue()) : 0777; if (runtime.getPosix().mkdir(newDir.getAbsolutePath(), mode) < 0) { // FIXME: This is a system error based on errno throw runtime.newSystemCallError("mkdir failed"); } return RubyFixnum.zero(runtime); }