-/*
- * Created on 06.09.2003
- *
- * To change the template for this generated file go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
package net.sourceforge.phpeclipse.builder;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
-import net.sourceforge.phpdt.internal.ui.util.StreamUtil;
+import net.sourceforge.phpdt.internal.core.util.StreamUtil;
import net.sourceforge.phpeclipse.PHPeclipsePlugin;
import org.eclipse.core.resources.IStorage;
*/
/**
- *
+ *
* @see IStorage
*/
public class FileStorage extends PlatformObject implements IStorage {
- private boolean forceReadOnly;
- private final IPath path;
- private final File file;
-
- /**
- * Two FileStorages are equal if their IPaths are equal.
- * @see java.lang.Object#equals(java.lang.Object)
- */
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (!(obj instanceof FileStorage))
- return false;
- FileStorage other = (FileStorage) obj;
- return path.equals(other.path);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.resources.IStorage#getContents()
- */
- public InputStream getContents() throws CoreException {
- try {
- return new FileInputStream(file);
- } catch (FileNotFoundException e) {
- throw new CoreException(new Status(IStatus.ERROR, PHPeclipsePlugin.PLUGIN_ID, IStatus.ERROR, e.toString(), e));
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.resources.IStorage#getFullPath()
- */
- public IPath getFullPath() {
- return this.path;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.resources.IStorage#getName()
- */
- public String getName() {
- return this.path.lastSegment();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.resources.IStorage#isReadOnly()
- */
- public boolean isReadOnly() {
- return forceReadOnly || !file.canWrite();
- }
-
- /**
- * Method FileStorage.
- * @param path
- */
- public FileStorage(IPath path) {
- this.path = path;
- this.file = path.toFile();
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#toString()
- */
- public String toString() {
- return path.toOSString();
- }
-
- /**
- * @param stream
- * @param overwrite
- * @param b
- * @param monitor
- */
- public void setContents(InputStream stream, boolean overwrite, boolean b, IProgressMonitor monitor) throws CoreException {
- try {
- StreamUtil.transferStreams(stream, new FileOutputStream(file));
- } catch (FileNotFoundException e) {
- throw new CoreException(new Status(IStatus.ERROR, PHPeclipsePlugin.PLUGIN_ID, IStatus.ERROR, e.toString(), e));
- } catch (IOException e) {
- throw new CoreException(new Status(IStatus.ERROR, PHPeclipsePlugin.PLUGIN_ID, IStatus.ERROR, e.toString(), e));
- }
- }
-
- /**
- * Some document providers (notably CompilationUnitDocumentProvider)
- * can't handle read/write storage.
- */
- public void setReadOnly() {
- forceReadOnly = true;
- }
+ private boolean forceReadOnly;
+
+ private final IPath path;
+
+ private final File file;
+
+ /**
+ * Two FileStorages are equal if their IPaths are equal.
+ *
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (!(obj instanceof FileStorage))
+ return false;
+ FileStorage other = (FileStorage) obj;
+ return path.equals(other.path);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.core.resources.IStorage#getContents()
+ */
+ public InputStream getContents() throws CoreException {
+ try {
+ return new FileInputStream(file);
+ } catch (FileNotFoundException e) {
+ throw new CoreException(new Status(IStatus.ERROR,
+ PHPeclipsePlugin.PLUGIN_ID, IStatus.ERROR, e.toString(), e));
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.core.resources.IStorage#getFullPath()
+ */
+ public IPath getFullPath() {
+ return this.path;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.core.resources.IStorage#getName()
+ */
+ public String getName() {
+ return this.path.lastSegment();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.core.resources.IStorage#isReadOnly()
+ */
+ public boolean isReadOnly() {
+ return forceReadOnly || !file.canWrite();
+ }
+
+ /**
+ * Method FileStorage.
+ *
+ * @param path
+ */
+ public FileStorage(IPath path) {
+ this.path = path;
+ this.file = path.toFile();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#toString()
+ */
+ public String toString() {
+ return path.toOSString();
+ }
+
+ /**
+ * @param stream
+ * @param overwrite
+ * @param b
+ * @param monitor
+ */
+ public void setContents(InputStream stream, boolean overwrite, boolean b,
+ IProgressMonitor monitor) throws CoreException {
+ try {
+ StreamUtil.transferStreams(stream, new FileOutputStream(file));
+ } catch (FileNotFoundException e) {
+ throw new CoreException(new Status(IStatus.ERROR,
+ PHPeclipsePlugin.PLUGIN_ID, IStatus.ERROR, e.toString(), e));
+ } catch (IOException e) {
+ throw new CoreException(new Status(IStatus.ERROR,
+ PHPeclipsePlugin.PLUGIN_ID, IStatus.ERROR, e.toString(), e));
+ }
+ }
+
+ /**
+ * Some document providers (notably CompilationUnitDocumentProvider) can't
+ * handle read/write storage.
+ */
+ public void setReadOnly() {
+ forceReadOnly = true;
+ }
}