/** * Gets the SIdChain for the given stream Id * * @param pSId the stream Id * @param pStreamSize the size of the stream, or -1 for system control streams * @return the SIdChain for the given stream Id * @throws IOException if an I/O exception occurs */ private SIdChain getSIdChain(final int pSId, final long pStreamSize) throws IOException { SIdChain chain = new SIdChain(); int[] sat = isShortStream(pStreamSize) ? shortSAT : SAT; int sid = pSId; while (sid != END_OF_CHAIN_SID && sid != FREE_SID) { chain.addSID(sid); sid = sat[sid]; } return chain; }
void addSID(int pSID) { ensureCapacity(); chain[size++] = pSID; }
private boolean fillBuffer() throws IOException { if (streamPos < length && nextSectorPos < chain.length()) { // TODO: Sync on document.input here, and we are completely detached... :-) // TODO: Update: We also need to sync other places... :-P synchronized (document) { document.seekToSId(chain.get(nextSectorPos), length); document.input.readFully(buffer); } nextSectorPos++; bufferPos = 0; return true; } return false; }
private void readSAT() throws IOException { if (SAT != null) { return; } final int intsPerSector = sectorSize / 4; // Read the Sector Allocation Table SAT = new int[masterSAT.length * intsPerSector]; for (int i = 0; i < masterSAT.length; i++) { seekToSId(masterSAT[i], FREE_SID); for (int j = 0; j < intsPerSector; j++) { int nextSID = input.readInt(); int index = (j + (i * intsPerSector)); SAT[index] = nextSID; } } // Read the short-stream Sector Allocation Table SIdChain chain = getSIdChain(shortSATSId, FREE_SID); shortSAT = new int[shortSATSize * intsPerSector]; for (int i = 0; i < shortSATSize; i++) { seekToSId(chain.get(i), FREE_SID); for (int j = 0; j < intsPerSector; j++) { int nextSID = input.readInt(); int index = (j + (i * intsPerSector)); shortSAT[index] = nextSID; } } }
+ (shortStreamSIdChain.get(offset) * (long) sectorSize) + (shortOffset * (long) shortSectorSize);
private boolean fillBuffer() throws IOException { if (streamPos < length && nextSectorPos < chain.length()) { // TODO: Sync on document.input here, and we are completely detached... :-) // TODO: Update: We also need to sync other places... :-P synchronized (document) { document.seekToSId(chain.get(nextSectorPos), length); document.input.readFully(buffer); } nextSectorPos++; bufferPos = 0; return true; } return false; }
/** * Gets the SIdChain for the given stream Id * * @param pSId the stream Id * @param pStreamSize the size of the stream, or -1 for system control streams * @return the SIdChain for the given stream Id * @throws IOException if an I/O exception occurs */ private SIdChain getSIdChain(final int pSId, final long pStreamSize) throws IOException { SIdChain chain = new SIdChain(); int[] sat = isShortStream(pStreamSize) ? mShortSAT : mSAT; int sid = pSId; while (sid != END_OF_CHAIN_SID && sid != FREE_SID) { chain.addSID(sid); sid = sat[sid]; } return chain; }
private void seekToDId(final int pDId) throws IOException { if (directorySIdChain == null) { directorySIdChain = getSIdChain(directorySId, FREE_SID); } int dIdsPerSId = sectorSize / Entry.LENGTH; int sIdOffset = pDId / dIdsPerSId; int dIdOffset = pDId - (sIdOffset * dIdsPerSId); int sId = directorySIdChain.get(sIdOffset); seekToSId(sId, FREE_SID); if (input instanceof LittleEndianRandomAccessFile) { LittleEndianRandomAccessFile input = (LittleEndianRandomAccessFile) this.input; input.seek(input.getFilePointer() + dIdOffset * Entry.LENGTH); } else if (input instanceof ImageInputStream) { ImageInputStream input = (ImageInputStream) this.input; input.seek(input.getStreamPosition() + dIdOffset * Entry.LENGTH); } else { SeekableLittleEndianDataInputStream input = (SeekableLittleEndianDataInputStream) this.input; input.seek(input.getStreamPosition() + dIdOffset * Entry.LENGTH); } }
void addSID(int pSID) { ensureCapacity(); chain[size++] = pSID; }
private boolean fillBuffer() throws IOException { if (mNextSectorPos < mChain.length()) { // TODO: Sync on mDocument.mInput here, and we are completely detached... :-) // TODO: We also need to sync other places... synchronized (mDocument) { mDocument.seekToSId(mChain.get(mNextSectorPos), mLength); mDocument.mInput.readFully(mBuffer); } mNextSectorPos++; mBufferPos = 0; return true; } return false; }
/** * Gets the SIdChain for the given stream Id * * @param pSId the stream Id * @param pStreamSize the size of the stream, or -1 for system control streams * @return the SIdChain for the given stream Id * @throws IOException if an I/O exception occurs */ private SIdChain getSIdChain(final int pSId, final long pStreamSize) throws IOException { SIdChain chain = new SIdChain(); int[] sat = isShortStream(pStreamSize) ? shortSAT : SAT; int sid = pSId; while (sid != END_OF_CHAIN_SID && sid != FREE_SID) { chain.addSID(sid); sid = sat[sid]; } return chain; }
private void readSAT() throws IOException { if (SAT != null) { return; } final int intsPerSector = sectorSize / 4; // Read the Sector Allocation Table SAT = new int[masterSAT.length * intsPerSector]; for (int i = 0; i < masterSAT.length; i++) { seekToSId(masterSAT[i], FREE_SID); for (int j = 0; j < intsPerSector; j++) { int nextSID = input.readInt(); int index = (j + (i * intsPerSector)); SAT[index] = nextSID; } } // Read the short-stream Sector Allocation Table SIdChain chain = getSIdChain(shortSATSId, FREE_SID); shortSAT = new int[shortSATSize * intsPerSector]; for (int i = 0; i < shortSATSize; i++) { seekToSId(chain.get(i), FREE_SID); for (int j = 0; j < intsPerSector; j++) { int nextSID = input.readInt(); int index = (j + (i * intsPerSector)); shortSAT[index] = nextSID; } } }
void addSID(int pSID) { ensureCapacity(); chain[size++] = pSID; }
private void readSAT() throws IOException { if (mSAT != null) { return; } final int intsPerSector = mSectorSize / 4; // Read the Sector Allocation Table mSAT = new int[mMasterSAT.length * intsPerSector]; for (int i = 0; i < mMasterSAT.length; i++) { seekToSId(mMasterSAT[i], FREE_SID); for (int j = 0; j < intsPerSector; j++) { int nextSID = mInput.readInt(); int index = (j + (i * intsPerSector)); mSAT[index] = nextSID; } } // Read the short-stream Sector Allocation Table SIdChain chain = getSIdChain(mShortSATSID, FREE_SID); mShortSAT = new int[mShortSATSize * intsPerSector]; for (int i = 0; i < mShortSATSize; i++) { seekToSId(chain.get(i), FREE_SID); for (int j = 0; j < intsPerSector; j++) { int nextSID = mInput.readInt(); int index = (j + (i * intsPerSector)); mShortSAT[index] = nextSID; } } }
+ (mShortStreamSIdChain.get(offset) * (long) mSectorSize) + (shortOffset * (long) mShortSectorSize);
+ (shortStreamSIdChain.get(offset) * (long) sectorSize) + (shortOffset * (long) shortSectorSize);
private void seekToDId(final int pDId) throws IOException { if (mDirectorySIdChain == null) { mDirectorySIdChain = getSIdChain(mDirectorySId, FREE_SID); } int dIdsPerSId = mSectorSize / Entry.LENGTH; int sIdOffset = pDId / dIdsPerSId; int dIdOffset = pDId - (sIdOffset * dIdsPerSId); int sId = mDirectorySIdChain.get(sIdOffset); seekToSId(sId, FREE_SID); if (mInput instanceof LittleEndianRandomAccessFile) { LittleEndianRandomAccessFile input = (LittleEndianRandomAccessFile) mInput; input.seek(input.getFilePointer() + dIdOffset * Entry.LENGTH); } else if (mInput instanceof ImageInputStream) { ImageInputStream input = (ImageInputStream) mInput; input.seek(input.getStreamPosition() + dIdOffset * Entry.LENGTH); } else { SeekableLittleEndianDataInputStream input = (SeekableLittleEndianDataInputStream) mInput; input.seek(input.getStreamPosition() + dIdOffset * Entry.LENGTH); } }
private void seekToDId(final int pDId) throws IOException { if (directorySIdChain == null) { directorySIdChain = getSIdChain(directorySId, FREE_SID); } int dIdsPerSId = sectorSize / Entry.LENGTH; int sIdOffset = pDId / dIdsPerSId; int dIdOffset = pDId - (sIdOffset * dIdsPerSId); int sId = directorySIdChain.get(sIdOffset); seekToSId(sId, FREE_SID); if (input instanceof LittleEndianRandomAccessFile) { LittleEndianRandomAccessFile input = (LittleEndianRandomAccessFile) this.input; input.seek(input.getFilePointer() + dIdOffset * Entry.LENGTH); } else if (input instanceof ImageInputStream) { ImageInputStream input = (ImageInputStream) this.input; input.seek(input.getStreamPosition() + dIdOffset * Entry.LENGTH); } else { SeekableLittleEndianDataInputStream input = (SeekableLittleEndianDataInputStream) this.input; input.seek(input.getStreamPosition() + dIdOffset * Entry.LENGTH); } }