List of usage examples for org.apache.commons.vfs FileObject isReadable
public boolean isReadable() throws FileSystemException;
From source file:r.base.Files.java
/** * Gets the type or storage mode of an object. /*from ww w . j a v a 2 s. c o m*/ * @return unix-style file mode integer */ private static int mode(FileObject file) throws FileSystemException { int access = 0; if (file.isReadable()) { access += 4; } if (file.isWriteable()) { access += 2; } if (file.getType() == FileType.FOLDER) { access += 1; } // i know this is braindead but i can't be bothered // to do octal math at the moment String digit = Integer.toString(access); String octalString = digit + digit + digit; return Integer.parseInt(octalString, 8); }
From source file:rsc.backend.modules.ips.IPS.java
public void connectionConnect() { try {//w w w. j a va2 s . c o m Connection c = host.getConnection(); FileObject fo = c.getFileSystem().resolveFile(snortConf); if (!fo.isWriteable() && fo.isReadable()) { JOptionPane.showMessageDialog(null, "cant write to snort.conf - your changes might be lost", "snort configuration", JOptionPane.INFORMATION_MESSAGE); } if (!fo.isReadable()) { JOptionPane.showMessageDialog(null, "cant read snort.conf", "snort configuration error", JOptionPane.ERROR_MESSAGE); } conf = SnortFactoryParser.createInstance(fo.getContent().getInputStream());//new Snortconf(fo.getContent().getInputStream()); fireChangeEvent(); } catch (ConfigurationException ex) { IPS.log(Level.SEVERE, "cant configure ips-configuration", ex); } catch (FileSystemException ex) { IPS.log(Level.SEVERE, "cant read ips-configuration", ex); } catch (Exception ex) { Logger.getLogger(IPS.class.getName()).log(Level.SEVERE, null, ex); } }