@Override public boolean isReadOnly() { return mFio.isReadOnly(); }
@Override public boolean isEmpty() throws IOException { return mFio.length() == 0; }
public static FileIO open(File file, EnumSet<OpenOption> options) throws IOException { return open(file, options, 32); }
@Override public void readPage(long index, long dstPtr, int offset, int length) throws IOException { if (index < 0) { throw new IndexOutOfBoundsException(String.valueOf(index)); } mFio.read(index * mPageSize, dstPtr, offset, length); }
@Override public void writePage(long index, long srcPtr, int offset) throws IOException { int pageSize = mPageSize; mFio.write(index * pageSize, srcPtr, offset, pageSize); }
FileIO.dirSync(file); } catch (IOException e) { Utils.closeQuietly(null, fout);
/** * Attempt to set the length of the file. It isn't critical that the * operation succeed, and so any exceptions can be suppressed. */ public abstract void setLength(long length, LengthOption option) throws IOException;
private void doSync() throws IOException { FileIO io = mFileIO; while (true) { if (io != null || (io = fileIO()) != null) trySync: { try { io.sync(false); return; } catch (IOException e) { acquireExclusive(); if (mFileIO == io) { releaseExclusive(); throw e; } } } try { if (mMaxLength == 0 || (io = openForWriting()) == null) { return; } } finally { releaseExclusive(); } } }
void close(boolean permanent) throws IOException { if (mFileIO != null) { mFileIO.close(); mFileIO = null; } if (permanent) { mSegmentClosed = true; } }
@Override public void readPage(long index, byte[] dst, int offset, int length) throws IOException { if (index < 0) { throw new IndexOutOfBoundsException(String.valueOf(index)); } mFio.read(index * mPageSize, dst, offset, length); }
@Override public void writePage(long index, byte[] src, int offset) throws IOException { int pageSize = mPageSize; mFio.write(index * pageSize, src, offset, pageSize); }
FileIO.dirSync(file); } catch (IOException e) { Utils.closeQuietly(null, fout);
@Override public void setPageCount(long count) throws IOException { if (count < 0) { throw new IllegalArgumentException(String.valueOf(count)); } if (isReadOnly()) { return; } mFio.setLength(count * mPageSize); }
@Override public void close() throws IOException { close(null); }
public static FileIO open(File file, EnumSet<OpenOption> options) throws IOException { return open(file, options, 32); }