X-Git-Url: http://git.phpeclipse.com diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/builder/FileStorage.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/builder/FileStorage.java index d4b5f6a..4bb9ac8 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/builder/FileStorage.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/builder/FileStorage.java @@ -24,96 +24,114 @@ import org.eclipse.core.runtime.Status; */ /** - * + * * @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; + } }