1 11 package org.eclipse.pde.internal.ui.editor; 12 13 import java.io.File ; 14 import java.io.FileInputStream ; 15 import java.io.FileNotFoundException ; 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.pde.internal.ui.PDEPlugin; 26 27 public class SystemFileStorage extends PlatformObject implements IStorage { 28 private File file; 29 32 public SystemFileStorage(File file) { 33 this.file = file; 34 } 35 36 public File getFile() { 37 return file; 38 } 39 public InputStream getContents() throws CoreException { 40 try { 41 return new FileInputStream (file); 42 } catch (FileNotFoundException e) { 43 IStatus status = 44 new Status(IStatus.ERROR, PDEPlugin.getPluginId(), IStatus.OK, null, e); 45 throw new CoreException(status); 46 } 47 } 48 public IPath getFullPath() { 49 return new Path(file.getAbsolutePath()); 50 } 51 public String getName() { 52 return file.getName(); 53 } 54 public boolean isReadOnly() { 55 return true; 56 } 57 58 public boolean equals(Object object) { 59 return object instanceof SystemFileStorage 60 && getFile().equals(((SystemFileStorage) object).getFile()); 61 } 62 63 public int hashCode() { 64 return getFile().hashCode(); 65 } 66 } 67 | Popular Tags |