Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2005, 2007 IBM Corporation and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html Contributors: IBM Corporation - initial API and implementation /
 
 package org.eclipse.team.internal.ccvs.ui.operations;
 
 import java.io.*;
 
 
 public class FileDiffOperation extends DiffOperation {
 
 	
 	public FileDiffOperation(IWorkbenchPart partResourceMapping[] mappingsLocalOption[] optionsFile fileboolean isMultiPatchboolean includeFullPathInformationIPath patchRoot) {
 		super(partmappingsoptionsisMultiPatchincludeFullPathInformationpatchRootfile.getAbsolutePath());
 		IPath teamLocation= TeamPlugin.getPlugin().getStateLocation();
 		IPath tempFilePath = teamLocation.append(new Path(. + "tempDiff" + System.currentTimeMillis())); //$NON-NLS-1$
 		 = tempFilePath.toFile();
 		this. = file;
 	}
 
 	public void execute(IProgressMonitor monitorthrows CVSExceptionInterruptedException {
 	    super.execute(monitor);
      
 		if (.length() == 0) {
 			return;
 		}	
 		
 		if (this. &&
 			return;
 		}
 		
 		 copyFile();
 	}
 	
 	protected void copyFile() throws CVSException {
 		FileChannel tempFileChannel=null;
 		FileChannel fileChannel=null;
 		try {
 		    tempFileChannel = new FileInputStream().getChannel();
 		    fileChannel = new FileOutputStream().getChannel();
 		
 		    long sizetempFileChannel.size();
 			long bytesTransferred = fileChannel.transferFrom(tempFileChannel, 0, size);
 		    while (bytesTransferred != size){
 		    	//Transfer from point left off until the end of the file
 		    	bytesTransferred += fileChannel.transferFrom(tempFileChannelbytesTransferredsize);
 		    }
 		} catch (IOException e) {
 			throw CVSException.wrapException(e); 
 		} finally {
 			if (tempFileChannel!=null)
 				try {
 					tempFileChannel.close();
 				} catch (IOException e) {
 					throw CVSException.wrapException(e); 
 				}
 			
 			if (fileChannel!=null)
 				try {
 					fileChannel.close();
 				} catch (IOException e) {
 					throw CVSException.wrapException(e); 
 				}
 				
 			if ( != null)
 		}
 	}
 
 	/* (non-Javadoc)
 	 * @see org.eclipse.team.internal.ccvs.ui.operations.DiffOperation#openStream()
 	 */
 	protected PrintStream openStream() throws CVSException {
 		try {
			return new PrintStream();
catch (FileNotFoundException e) {
			throw new CVSException(status); 
		}
	}
New to GrepCode? Check out our FAQ X