Bug 532401: [Resources] write commands do not throw on error
Change-Id: I1119b97f65c0be67e2a26f8857d8c76d8511be7a
diff --git a/plugins/org.eclipse.ease.modules.platform/src/org/eclipse/ease/modules/platform/FilesystemHandle.java b/plugins/org.eclipse.ease.modules.platform/src/org/eclipse/ease/modules/platform/FilesystemHandle.java
index 1f43e20..a7c722d 100644
--- a/plugins/org.eclipse.ease.modules.platform/src/org/eclipse/ease/modules/platform/FilesystemHandle.java
+++ b/plugins/org.eclipse.ease.modules.platform/src/org/eclipse/ease/modules/platform/FilesystemHandle.java
@@ -83,41 +83,27 @@
}
@Override
- public boolean write(final String data) {
- try {
- // replace file content or append content
- if (fWriter == null) {
- if (fOutput == null)
- fOutput = new BufferedOutputStream(new FileOutputStream(fFile, (fMode & APPEND) == APPEND));
-
- fWriter = new PrintWriter(new OutputStreamWriter(fOutput));
- }
-
- fWriter.print(data);
- fWriter.flush();
- return true;
-
- } catch (final Exception e) {
- }
-
- return false;
- }
-
- @Override
- public boolean write(final byte[] data) {
- try {
- // replace file content or append content
+ public void write(final String data) throws IOException {
+ // replace file content or append content
+ if (fWriter == null) {
if (fOutput == null)
fOutput = new BufferedOutputStream(new FileOutputStream(fFile, (fMode & APPEND) == APPEND));
- fOutput.write(data);
- fOutput.flush();
- return true;
-
- } catch (final Exception e) {
+ fWriter = new PrintWriter(new OutputStreamWriter(fOutput));
}
- return false;
+ fWriter.print(data);
+ fWriter.flush();
+ }
+
+ @Override
+ public void write(final byte[] data) throws IOException {
+ // replace file content or append content
+ if (fOutput == null)
+ fOutput = new BufferedOutputStream(new FileOutputStream(fFile, (fMode & APPEND) == APPEND));
+
+ fOutput.write(data);
+ fOutput.flush();
}
protected static StringBuilder read(final Reader reader) throws IOException {
diff --git a/plugins/org.eclipse.ease.modules.platform/src/org/eclipse/ease/modules/platform/IFileHandle.java b/plugins/org.eclipse.ease.modules.platform/src/org/eclipse/ease/modules/platform/IFileHandle.java
index 0d1d028..33b1120 100644
--- a/plugins/org.eclipse.ease.modules.platform/src/org/eclipse/ease/modules/platform/IFileHandle.java
+++ b/plugins/org.eclipse.ease.modules.platform/src/org/eclipse/ease/modules/platform/IFileHandle.java
@@ -54,18 +54,20 @@
*
* @param data
* data to write
- * @return <code>true</code> on success
+ * @throws IOException
+ * on write errors
*/
- boolean write(String data);
+ void write(String data) throws IOException;
/**
* Write data to a file.
*
* @param data
* data to write
- * @return <code>true</code> on success
+ * @throws IOException
+ * on write errors
*/
- boolean write(byte[] data);
+ void write(byte[] data) throws IOException;
/**
* Check if a physical file exists.
diff --git a/plugins/org.eclipse.ease.modules.platform/src/org/eclipse/ease/modules/platform/ResourceHandle.java b/plugins/org.eclipse.ease.modules.platform/src/org/eclipse/ease/modules/platform/ResourceHandle.java
index df64279..5e9abd4 100644
--- a/plugins/org.eclipse.ease.modules.platform/src/org/eclipse/ease/modules/platform/ResourceHandle.java
+++ b/plugins/org.eclipse.ease.modules.platform/src/org/eclipse/ease/modules/platform/ResourceHandle.java
@@ -12,6 +12,7 @@
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
+import java.io.IOException;
import java.io.InputStreamReader;
import org.eclipse.core.resources.IContainer;
@@ -36,12 +37,12 @@
}
@Override
- public boolean write(final String data) {
- return write(data.getBytes());
+ public void write(final String data) throws IOException {
+ write(data.getBytes());
}
@Override
- public boolean write(final byte[] data) {
+ public void write(final byte[] data) throws IOException {
try {
// replace file content or append content
if ((getMode() & APPEND) == APPEND) {
@@ -54,12 +55,9 @@
setMode(getMode() | APPEND);
}
- return true;
-
- } catch (final Exception e) {
+ } catch (final CoreException e) {
+ throw new IOException(e.getMessage(), e);
}
-
- return false;
}
@Override