@Override public void close() throws IOException { buffer.close(); }
public static Stat fstat(FileDescriptor fd) throws IOException { NativeBuffer nativeBuffer = new NativeBuffer(92, ByteOrder.nativeOrder()); try { DirectMemory direct = nativeBuffer.memory(); try { int err = fstat(fdField.getInt(fd), direct.getAddress()); if (err == errstr.indexOf("ENOENT")) { throw new FileNotFoundException("No such file or directory"); } if (err != 0) { throw new IOException("fstat on file descriptor "+fd+" failed with error "+(err < 0 ? "unknown" : errstr.get(err))); } } catch (IllegalAccessException e) { throw Throwables.propagate(e); } return new Stat(direct); } finally { nativeBuffer.close(); } }
public static Stat lstat(String file) throws IOException { NativeBuffer nativeBuffer = new NativeBuffer(92, ByteOrder.nativeOrder()); try { DirectMemory direct = nativeBuffer.memory(); int err = lstat(file, direct.getAddress()); if (err == errstr.indexOf("ENOENT")) { throw new FileNotFoundException("No such file or directory: "+file); } if (err != 0) { throw new IOException("stat on path "+file+" failed with error "+(err < 0 ? "unknown" : errstr.get(err))); } return new Stat(direct); } finally { nativeBuffer.close(); } }
public static Stat stat(String file) throws IOException { NativeBuffer nativeBuffer = new NativeBuffer(92, ByteOrder.nativeOrder()); try { DirectMemory direct = nativeBuffer.memory(); int err = stat(file, direct.getAddress()); if (err != 0) { if (err == errstr.indexOf("ENOENT")) { throw new FileNotFoundException("No such file or directory: "+file); } throw new IOException("stat on path "+file+" failed with error "+(err < 0 ? "unknown" : errstr.get(err))); } return new Stat(direct); } finally { nativeBuffer.close(); } }