01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.pde.internal.ui.editor;
11:
12: import java.io.File;
13: import java.io.FileInputStream;
14: import java.io.FileNotFoundException;
15: import java.io.InputStream;
16:
17: import org.eclipse.core.resources.IStorage;
18: import org.eclipse.core.runtime.CoreException;
19: import org.eclipse.core.runtime.IPath;
20: import org.eclipse.core.runtime.IStatus;
21: import org.eclipse.core.runtime.Path;
22: import org.eclipse.core.runtime.PlatformObject;
23: import org.eclipse.core.runtime.Status;
24: import org.eclipse.pde.internal.ui.PDEPlugin;
25:
26: public class SystemFileStorage extends PlatformObject implements
27: IStorage {
28: private File file;
29:
30: /**
31: * Constructor for SystemFileStorage.
32: */
33: public SystemFileStorage(File file) {
34: this .file = file;
35: }
36:
37: public File getFile() {
38: return file;
39: }
40:
41: public InputStream getContents() throws CoreException {
42: try {
43: return new FileInputStream(file);
44: } catch (FileNotFoundException e) {
45: IStatus status = new Status(IStatus.ERROR, PDEPlugin
46: .getPluginId(), IStatus.OK, null, e);
47: throw new CoreException(status);
48: }
49: }
50:
51: public IPath getFullPath() {
52: return new Path(file.getAbsolutePath());
53: }
54:
55: public String getName() {
56: return file.getName();
57: }
58:
59: public boolean isReadOnly() {
60: return true;
61: }
62:
63: public boolean equals(Object object) {
64: return object instanceof SystemFileStorage
65: && getFile().equals(
66: ((SystemFileStorage) object).getFile());
67: }
68:
69: public int hashCode() {
70: return getFile().hashCode();
71: }
72: }
|