1 11 package org.eclipse.team.internal.ccvs.ui.operations; 12 13 import java.io.*; 14 15 import org.eclipse.core.resources.*; 16 import org.eclipse.core.resources.mapping.ResourceMapping; 17 import org.eclipse.core.runtime.*; 18 import org.eclipse.team.internal.ccvs.core.CVSException; 19 import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption; 20 import org.eclipse.ui.IWorkbenchPart; 21 22 public class WorkspaceFileDiffOperation extends FileDiffOperation { 23 24 public WorkspaceFileDiffOperation(IWorkbenchPart part, ResourceMapping[] mappings, LocalOption[] options, File file, boolean isMultiPatch, boolean includeFullPathInformation, IPath patchRoot) { 25 super(part, mappings, options, file, isMultiPatch, includeFullPathInformation, patchRoot); 26 } 27 28 protected void copyFile() throws CVSException { 29 30 IWorkspaceRoot root =ResourcesPlugin.getWorkspace().getRoot(); 31 IFile finalFile = root.getFileForLocation(new Path(this.file.getPath())); 32 InputStream fileInputStream = null; 33 try { 34 fileInputStream = new BufferedInputStream(new FileInputStream(tempFile)); 35 if(!finalFile.exists()) { 36 finalFile.create(fileInputStream, IResource.FORCE , null); 37 } else { 38 finalFile.setContents(fileInputStream, IResource.FORCE, null); 39 } 40 } catch (FileNotFoundException e) { 41 throw CVSException.wrapException(e); 42 } catch (CoreException e) { 43 throw CVSException.wrapException(e); 44 } 45 finally{ 46 if (fileInputStream != null) { 47 try { 48 fileInputStream.close(); 49 } catch (IOException e) { 50 } finally { 52 if (tempFile != null) 53 tempFile.delete(); 54 } 55 } 56 } 57 } 58 59 } 60 | Popular Tags |