@Override public int getMode() { return stat.mode(); }
public Integer invoke(File f, VirtualChannel channel) throws IOException { return PosixAPI.get().stat(f.getPath()).mode(); } });
@Override public int mode(File file) { try { return PosixAPI.get().stat(file.getPath()).mode(); } catch (Throwable ex) { throw new NativeAccessException("Failed to get File mode. " + ex.getLocalizedMessage()); } }
public Integer invoke(File f, VirtualChannel channel) throws IOException { return PosixAPI.get().stat(f.getPath()).mode(); } });
@Override public boolean makeFileWritable(File file) { try { POSIX posix = PosixAPI.get(); String path = file.getAbsolutePath(); FileStat stat = posix.stat(path); return posix.chmod(path, stat.mode() | 0200) == 0; // u+w } catch (Throwable ex) { throw new NativeAccessException("Failed to make file writable. " + ex.getLocalizedMessage()); } }
@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())).append(", "); } catch (Exception e) {} try { buf.append("ino=").append(stat.ino()).append(", "); } catch (Exception e) {} buf.append("mode=0").append(Integer.toOctalString(stat.mode())).append(", "); try { buf.append("nlink=").append(stat.nlink()).append(", "); } catch (Exception e) {} try { buf.append("uid=").append(stat.uid()).append(", "); } catch (Exception e) {} try { buf.append("gid=").append(stat.gid()).append(", "); } catch (Exception e) {} try { buf.append("rdev=0x").append(Long.toHexString(stat.rdev())).append(", "); } catch (Exception e) {} buf.append("size=").append(stat.st_size()).append(", "); try { buf.append("blksize=").append(stat.blockSize()).append(", "); } catch (Exception e) {} try { buf.append("blocks=").append(stat.blocks()).append(", "); } catch (Exception e) {} 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 = "mode") public IRubyObject mode() { return getRuntime().newFixnum(stat.mode()); }
/** * Makes the given file writable by any means possible. */ @IgnoreJRERequirement private static void makeWritable(File f) { // try chmod. this becomes no-op if this is not Unix. try { Chmod chmod = new Chmod(); chmod.setProject(new Project()); chmod.setFile(f); chmod.setPerm("u+w"); chmod.execute(); } catch (BuildException e) { LOGGER.log(Level.INFO,"Failed to chmod "+f,e); } // also try JDK6-way of doing it. try { f.setWritable(true); } catch (NoSuchMethodError e) { // not JDK6 } try {// try libc chmod POSIX posix = PosixAPI.get(); String path = f.getAbsolutePath(); FileStat stat = posix.stat(path); posix.chmod(path, stat.mode()|0200); // u+w } catch (Throwable t) { LOGGER.log(Level.FINE,"Failed to chmod(2) "+f,t); } }
/** * Makes the given file writable by any means possible. */ @IgnoreJRERequirement private static void makeWritable(File f) { // try chmod. this becomes no-op if this is not Unix. try { Chmod chmod = new Chmod(); chmod.setProject(new Project()); chmod.setFile(f); chmod.setPerm("u+w"); chmod.execute(); } catch (BuildException e) { LOGGER.log(Level.INFO,"Failed to chmod "+f,e); } // also try JDK6-way of doing it. try { f.setWritable(true); } catch (NoSuchMethodError e) { // not JDK6 } try {// try libc chmod POSIX posix = PosixAPI.get(); String path = f.getAbsolutePath(); FileStat stat = posix.stat(path); posix.chmod(path, stat.mode()|0200); // u+w } catch (Throwable t) { LOGGER.log(Level.FINE,"Failed to chmod(2) "+f,t); } }
else group=String.valueOf(st.gid()); if ((st.mode()&FileStat.S_IRGRP)!=0) {
else group=String.valueOf(st.gid()); if ((st.mode()&FileStat.S_IRGRP)!=0) {
if ((st.mode() & FileStat.S_IRGRP) != 0) {