@JRubyMethod(name = "inspect") public IRubyObject inspect() { StringBuilder buf = new StringBuilder("#<"); buf.append(getMetaClass().getRealClass().getName()); buf.append(" "); // FIXME: Obvious issue that not all platforms can display all attributes. Ugly hacks. // Using generic posix library makes pushing inspect behavior into specific system impls // rather painful. try { buf.append("dev=0x").append(Long.toHexString(stat.dev())); } catch (Exception e) {} finally { buf.append(", "); } try { buf.append("ino=").append(stat.ino()); } catch (Exception e) {} finally { buf.append(", "); } buf.append("mode=0").append(Integer.toOctalString(stat.mode())).append(", "); try { buf.append("nlink=").append(stat.nlink()); } catch (Exception e) {} finally { buf.append(", "); } try { buf.append("uid=").append(stat.uid()); } catch (Exception e) {} finally { buf.append(", "); } try { buf.append("gid=").append(stat.gid()); } catch (Exception e) {} finally { buf.append(", "); } try { buf.append("rdev=0x").append(Long.toHexString(stat.rdev())); } catch (Exception e) {} finally { buf.append(", "); } buf.append("size=").append(sizeInternal()).append(", "); try { buf.append("blksize=").append(stat.blockSize()); } catch (Exception e) {} finally { buf.append(", "); } try { buf.append("blocks=").append(stat.blocks()); } catch (Exception e) {} finally { buf.append(", "); } buf.append("atime=").append(atime()).append(", "); buf.append("mtime=").append(mtime()).append(", "); buf.append("ctime=").append(ctime()); buf.append(">"); return getRuntime().newString(buf.toString()); }
@JRubyMethod(name = "inspect") public IRubyObject inspect() { StringBuilder buf = new StringBuilder("#<"); buf.append(getMetaClass().getRealClass().getName()); buf.append(" "); // FIXME: Obvious issue that not all platforms can display all attributes. Ugly hacks. // Using generic posix library makes pushing inspect behavior into specific system impls // rather painful. try { buf.append("dev=0x").append(Long.toHexString(stat.dev())); } catch (Exception e) {} finally { buf.append(", "); } try { buf.append("ino=").append(stat.ino()); } catch (Exception e) {} finally { buf.append(", "); } buf.append("mode=0").append(Integer.toOctalString(stat.mode())).append(", "); try { buf.append("nlink=").append(stat.nlink()); } catch (Exception e) {} finally { buf.append(", "); } try { buf.append("uid=").append(stat.uid()); } catch (Exception e) {} finally { buf.append(", "); } try { buf.append("gid=").append(stat.gid()); } catch (Exception e) {} finally { buf.append(", "); } try { buf.append("rdev=0x").append(Long.toHexString(stat.rdev())); } catch (Exception e) {} finally { buf.append(", "); } buf.append("size=").append(sizeInternal()).append(", "); try { buf.append("blksize=").append(stat.blockSize()); } catch (Exception e) {} finally { buf.append(", "); } try { buf.append("blocks=").append(stat.blocks()); } catch (Exception e) {} finally { buf.append(", "); } buf.append("atime=").append(atime()).append(", "); buf.append("mtime=").append(mtime()).append(", "); buf.append("ctime=").append(ctime()); buf.append(">"); return getRuntime().newString(buf.toString()); }
@JRubyMethod(name = "uid") public IRubyObject uid() { return getRuntime().newFixnum(stat.uid()); }
@JRubyMethod(name = "uid") public IRubyObject uid() { return getRuntime().newFixnum(stat.uid()); }
buf.append("mode=0").append(Integer.toOctalString(stat.mode())).append(", "); try { buf.append("nlink=").append(stat.nlink()); } catch (Exception e) {} finally { buf.append(", "); } try { buf.append("uid=").append(stat.uid()); } catch (Exception e) {} finally { buf.append(", "); } try { buf.append("gid=").append(stat.gid()); } catch (Exception e) {} finally { buf.append(", "); } try { buf.append("rdev=0x").append(Long.toHexString(stat.rdev())); } catch (Exception e) {} finally { buf.append(", "); }
buf.append("mode=0").append(Integer.toOctalString(stat.mode())).append(", "); try { buf.append("nlink=").append(stat.nlink()); } catch (Exception e) {} finally { buf.append(", "); } try { buf.append("uid=").append(stat.uid()); } catch (Exception e) {} finally { buf.append(", "); } try { buf.append("gid=").append(stat.gid()); } catch (Exception e) {} finally { buf.append(", "); } try { buf.append("rdev=0x").append(Long.toHexString(stat.rdev())); } catch (Exception e) {} finally { buf.append(", "); }
@JRubyMethod(name = "uid") public IRubyObject uid() { checkInitialized(); return getRuntime().newFixnum(stat.uid()); }
@JRubyMethod(name = "uid") public IRubyObject uid() { checkInitialized(); return getRuntime().newFixnum(stat.uid()); }
private void inplaceEdit(ThreadContext context, String filename, String extension) throws RaiseException { File file = new File(filename); FileStat stat = runtime.getPosix().stat(filename); if (extension.length() > 0) { file.renameTo(new File(filename + extension)); } else { file.delete(); } createNewFile(file); runtime.getPosix().chmod(filename, stat.mode()); runtime.getPosix().chown(filename, stat.uid(), stat.gid()); runtime.getGlobalVariables().set("$stdout", (RubyIO) RubyFile.open(context, runtime.getFile(), new IRubyObject[]{runtime.newString(filename), runtime.newString("w")}, Block.NULL_BLOCK)); }
private void inplaceEdit(ThreadContext context, String filename, String extension) throws RaiseException { File file = new File(filename); FileStat stat = runtime.getPosix().stat(filename); if (!extension.equals("")) { file.renameTo(new File(filename + extension)); } else { file.delete(); } createNewFile(file); runtime.getPosix().chmod(filename, stat.mode()); runtime.getPosix().chown(filename, stat.uid(), stat.gid()); runtime.getGlobalVariables().set("$stdout", (RubyIO) RubyFile.open(context, runtime.getFile(), new IRubyObject[]{runtime.newString(filename), runtime.newString("w")}, Block.NULL_BLOCK)); } }
private void inplaceEdit(ThreadContext context, String filename, String extension) throws RaiseException { File file = new File(filename); FileStat stat = runtime.getPosix().stat(filename); if (extension.length() > 0) { file.renameTo(new File(filename + extension)); } else { file.delete(); } createNewFile(file); runtime.getPosix().chmod(filename, stat.mode()); runtime.getPosix().chown(filename, stat.uid(), stat.gid()); runtime.getGlobalVariables().set("$stdout", (RubyIO) RubyFile.open(context, runtime.getFile(), new IRubyObject[]{runtime.newString(filename), runtime.newString("w")}, Block.NULL_BLOCK)); }
private void inplaceEdit(ThreadContext context, String filename, String extension) throws RaiseException { File file = new File(filename); FileStat stat = runtime.getPosix().stat(filename); if (!extension.equals("")) { file.renameTo(new File(filename + extension)); } else { file.delete(); } createNewFile(file); runtime.getPosix().chmod(filename, stat.mode()); runtime.getPosix().chown(filename, stat.uid(), stat.gid()); runtime.getGlobalVariables().set("$stdout", (RubyIO) RubyFile.open(context, runtime.getFile(), new IRubyObject[]{runtime.newString(filename), runtime.newString("w")}, Block.NULL_BLOCK)); } }
public static PyStatResult fromFileStat(FileStat stat) { return new PyStatResult( Py.newInteger(stat.mode()), Py.newInteger(stat.ino()), Py.newLong(stat.dev()), Py.newInteger(stat.nlink()), Py.newInteger(stat.uid()), Py.newInteger(stat.gid()), Py.newInteger(stat.st_size()), Py.newFloat(stat.atime()), Py.newFloat(stat.mtime()), Py.newFloat(stat.ctime())); }