1 11 package org.eclipse.debug.core.sourcelookup.containers; 12 13 import java.io.File ; 14 import java.io.FileInputStream ; 15 import java.io.IOException ; 16 import java.io.InputStream ; 17 18 import org.eclipse.core.resources.IStorage; 19 import org.eclipse.core.runtime.CoreException; 20 import org.eclipse.core.runtime.IPath; 21 import org.eclipse.core.runtime.IStatus; 22 import org.eclipse.core.runtime.Path; 23 import org.eclipse.core.runtime.PlatformObject; 24 import org.eclipse.core.runtime.Status; 25 import org.eclipse.debug.core.DebugPlugin; 26 import org.eclipse.debug.internal.core.sourcelookup.SourceLookupMessages; 27 28 37 public class LocalFileStorage extends PlatformObject implements IStorage { 38 39 42 private File fFile; 43 44 49 public LocalFileStorage(File file){ 50 setFile(file); 51 } 52 53 56 public InputStream getContents() throws CoreException { 57 try { 58 return new FileInputStream (getFile()); 59 } catch (IOException e){ 60 throw new CoreException(new Status(IStatus.ERROR, DebugPlugin.getUniqueIdentifier(), DebugPlugin.INTERNAL_ERROR, SourceLookupMessages.LocalFileStorage_0, e)); 61 } 62 } 63 64 67 public IPath getFullPath() { 68 try { 69 return new Path(getFile().getCanonicalPath()); 70 } catch (IOException e) { 71 DebugPlugin.log(e); 72 return null; 73 } 74 } 75 76 79 public String getName() { 80 return getFile().getName(); 81 } 82 83 86 public boolean isReadOnly() { 87 return true; 88 } 89 90 95 private void setFile(File file) { 96 fFile = file; 97 } 98 99 104 public File getFile() { 105 return fFile; 106 } 107 108 111 public boolean equals(Object object) { 112 return object instanceof LocalFileStorage && 113 getFile().equals(((LocalFileStorage)object).getFile()); 114 } 115 116 119 public int hashCode() { 120 return getFile().hashCode(); 121 } 122 } 123 | Popular Tags |