/** * Log the operation. * * @param op the operation * @param fileName the file name(s) */ void log(int op, String fileName) { log(op, fileName, null, 0); }
@Override public FileChannel truncate(long newLength) throws IOException { rec.log(Recorder.TRUNCATE, name, null, newLength); channel.truncate(newLength); return this; }
@Override public int write(ByteBuffer src, long position) throws IOException { byte[] buff = src.array(); int len = src.remaining(); if (src.position() != 0 || len != buff.length) { byte[] b = new byte[len]; System.arraycopy(buff, src.arrayOffset() + src.position(), b, 0, len); buff = b; } int result = channel.write(src, position); rec.log(Recorder.WRITE, name, buff, position); return result; }
@Override public int write(ByteBuffer src) throws IOException { byte[] buff = src.array(); int len = src.remaining(); if (src.position() != 0 || len != buff.length) { byte[] b = new byte[len]; System.arraycopy(buff, src.arrayOffset() + src.position(), b, 0, len); buff = b; } int result = channel.write(src); rec.log(Recorder.WRITE, name, buff, channel.position()); return result; }
@Override public void delete() { log(Recorder.DELETE, name); super.delete(); }
@Override public boolean createFile() { log(Recorder.CREATE_NEW_FILE, name); return super.createFile(); }
@Override public OutputStream newOutputStream(boolean append) throws IOException { log(Recorder.OPEN_OUTPUT_STREAM, name); return super.newOutputStream(append); }
@Override public FilePath createTempFile(String suffix, boolean deleteOnExit, boolean inTempDir) throws IOException { log(Recorder.CREATE_TEMP_FILE, unwrap(name) + ":" + suffix + ":" + deleteOnExit + ":" + inTempDir); return super.createTempFile(suffix, deleteOnExit, inTempDir); }
@Override public void moveTo(FilePath newPath, boolean atomicReplace) { log(Recorder.RENAME, unwrap(name) + ":" + unwrap(newPath.name)); super.moveTo(newPath, atomicReplace); }