/** * Returns true iff the file existed at the time the fingerprint was computed. * * @return true iff the file existed at the time the fingerprint was computed. */ public boolean fileExists() { return !equals(EMPTY); }
@Override public String toString() { return "FileFingerprint [time=" + getTimeString(this.time) + ", size=" + this.size + ", hash=" + this.hash + "]"; //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$ } }
hashCode = fileSize == 0 ? 0 : computeHashCode(path.toFile(), fileSize, subMonitor.split(90)); } catch (IOException e) { throw new CoreException(Package.createStatus("An error occurred computing a hash code", e)); //$NON-NLS-1$ FileFingerprint newFingerprint = new FileFingerprint(lastModified, fileSize, hashCode); return new FingerprintTestResult(matches, !equals(newFingerprint), newFingerprint);
private long computeHashCode(File toTest, long fileSize, IProgressMonitor monitor) throws IOException { final int BUFFER_SIZE = 2048; char[] charBuffer = new char[BUFFER_SIZE]; byte[] byteBuffer = new byte[BUFFER_SIZE * 2]; SubMonitor subMonitor = SubMonitor.convert(monitor, (int) (fileSize / (BUFFER_SIZE * 2))); StreamHasher hasher = new StreamHasher(); try { InputStream inputStream = new FileInputStream(toTest); try { while (true) { subMonitor.split(1); int bytesRead = readUntilBufferFull(inputStream, byteBuffer); if (bytesRead < byteBuffer.length) { charBuffer = new char[(bytesRead + 1) / 2]; copyByteArrayToCharArray(charBuffer, byteBuffer, bytesRead); hasher.addChunk(charBuffer); break; } copyByteArrayToCharArray(charBuffer, byteBuffer, bytesRead); hasher.addChunk(charBuffer); } } finally { inputStream.close(); } } catch (FileNotFoundException e) { return 0; } return hasher.computeHash(); }
if (fingerprint.fileExists()) { result = addElement(resourceFile, element, subMonitor.split(50)); fingerprint = FileFingerprint.getEmpty(); if (DEBUG && !fingerprint.fileExists()) { Package.log("the file " + pathString + " was not indexed because it does not exist", null); //$NON-NLS-1$ //$NON-NLS-2$
public FileFingerprint getFingerprint() { return new FileFingerprint( getTimeLastScanned(), getSizeLastScanned(), getHashcodeLastScanned()); }
for (IPath next : indexablesWithChanges) { FingerprintTestResult nextFingerprint = fingerprints.get(next); totalSizeToIndex += nextFingerprint.getNewFingerprint().getSize(); for (IPath next : indexablesWithChanges) { FingerprintTestResult nextFingerprint = fingerprints.get(next); int ticks = (int) (nextFingerprint.getNewFingerprint().getSize() * tickCoefficient);
hashCode = fileSize == 0 ? 0 : computeHashCode(path.toFile(), fileSize, subMonitor.split(90)); } catch (IOException e) { throw new CoreException(Package.createStatus("An error occurred computing a hash code", e)); //$NON-NLS-1$ FileFingerprint newFingerprint = new FileFingerprint(lastModified, fileSize, hashCode); return new FingerprintTestResult(matches, !equals(newFingerprint), newFingerprint);
private long computeHashCode(File toTest, long fileSize, IProgressMonitor monitor) throws IOException { final int BUFFER_SIZE = 2048; char[] charBuffer = new char[BUFFER_SIZE]; byte[] byteBuffer = new byte[BUFFER_SIZE * 2]; SubMonitor subMonitor = SubMonitor.convert(monitor, (int) (fileSize / (BUFFER_SIZE * 2))); StreamHasher hasher = new StreamHasher(); try { InputStream inputStream = new FileInputStream(toTest); try { while (true) { subMonitor.split(1); int bytesRead = readUntilBufferFull(inputStream, byteBuffer); if (bytesRead < byteBuffer.length) { charBuffer = new char[(bytesRead + 1) / 2]; copyByteArrayToCharArray(charBuffer, byteBuffer, bytesRead); hasher.addChunk(charBuffer); break; } copyByteArrayToCharArray(charBuffer, byteBuffer, bytesRead); hasher.addChunk(charBuffer); } } finally { inputStream.close(); } } catch (FileNotFoundException e) { return 0; } return hasher.computeHash(); }
if (fingerprint.fileExists()) { result = addElement(resourceFile, element, subMonitor.split(50)); fingerprint = FileFingerprint.getEmpty(); if (DEBUG && !fingerprint.fileExists()) { Package.log("the file " + pathString + " was not indexed because it does not exist", null); //$NON-NLS-1$ //$NON-NLS-2$
public FileFingerprint getFingerprint() { return new FileFingerprint( getTimeLastScanned(), getSizeLastScanned(), getHashcodeLastScanned()); }
for (IPath next : indexablesWithChanges) { FingerprintTestResult nextFingerprint = fingerprints.get(next); totalSizeToIndex += nextFingerprint.getNewFingerprint().getSize(); for (IPath next : indexablesWithChanges) { FingerprintTestResult nextFingerprint = fingerprints.get(next); int ticks = (int) (nextFingerprint.getNewFingerprint().getSize() * tickCoefficient);
@Override public String toString() { return "FileFingerprint [time=" + getTimeString(this.time) + ", size=" + this.size + ", hash=" + this.hash + "]"; //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$ } }
/** * Returns true iff the file existed at the time the fingerprint was computed. * * @return true iff the file existed at the time the fingerprint was computed. */ public boolean fileExists() { return !equals(EMPTY); }