Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorteicher2004-06-18 17:30:18 +0000
committerteicher2004-06-18 17:30:18 +0000
commit424073925cd7b115558c284446123230c3c2834e (patch)
tree25d2f31fbafc7e680043e2eb8311ee1d6aa860fe /org.eclipse.core.filebuffers
parent23c0d44bdc88a5a134ed9322e86a55583e6003f1 (diff)
downloadeclipse.platform.text-424073925cd7b115558c284446123230c3c2834e.tar.gz
eclipse.platform.text-424073925cd7b115558c284446123230c3c2834e.tar.xz
eclipse.platform.text-424073925cd7b115558c284446123230c3c2834e.zip
fixes 67437 [implementation] ClassCastException when performing saveAs
Diffstat (limited to 'org.eclipse.core.filebuffers')
-rw-r--r--org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ContainerGenerator.java20
-rw-r--r--org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/FileBuffersMessages.properties1
2 files changed, 17 insertions, 4 deletions
diff --git a/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ContainerGenerator.java b/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ContainerGenerator.java
index 06b806719..f64e0bb8e 100644
--- a/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ContainerGenerator.java
+++ b/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ContainerGenerator.java
@@ -20,8 +20,10 @@ import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubProgressMonitor;
public class ContainerGenerator {
@@ -78,9 +80,14 @@ public class ContainerGenerator {
// Does the container exist already?
IWorkspaceRoot root= fWorkspace.getRoot();
- fContainer= (IContainer) root.findMember(fContainerFullPath);
- if (fContainer != null)
+ IResource found= root.findMember(fContainerFullPath);
+ if (found instanceof IContainer) {
+ fContainer= (IContainer) found;
return;
+ } else if (found != null) {
+ // fContainerFullPath specifies a file as directory
+ throw new CoreException(new Status(IStatus.ERROR, FileBuffersPlugin.PLUGIN_ID, IStatus.OK, FileBuffersMessages.getFormattedString("ContainerGenerator.destinationMustBeAContainer", fContainerFullPath), null)); //$NON-NLS-1$
+ }
// Create the container for the given path
fContainer= root;
@@ -88,8 +95,13 @@ public class ContainerGenerator {
String currentSegment = fContainerFullPath.segment(i);
IResource resource = fContainer.findMember(currentSegment);
if (resource != null) {
- fContainer= (IContainer) resource;
- monitor.worked(1000);
+ if (resource instanceof IContainer) {
+ fContainer= (IContainer) resource;
+ monitor.worked(1000);
+ } else {
+ // fContainerFullPath specifies a file as directory
+ throw new CoreException(new Status(IStatus.ERROR, FileBuffersPlugin.PLUGIN_ID, IStatus.OK, FileBuffersMessages.getFormattedString("ContainerGenerator.destinationMustBeAContainer", resource.getFullPath()), null)); //$NON-NLS-1$
+ }
}
else {
if (i == 0) {
diff --git a/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/FileBuffersMessages.properties b/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/FileBuffersMessages.properties
index 271f2e84f..efbe8b0d3 100644
--- a/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/FileBuffersMessages.properties
+++ b/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/FileBuffersMessages.properties
@@ -21,6 +21,7 @@ FileBuffer.status.error= Error
FileBufferManager.error.canNotCreateFilebuffer= Cannot create file buffer.
ContainerGenerator.task.creatingContainer= Creating container...
+ContainerGenerator.destinationMustBeAContainer=Specified path is not a folder: {0}
ResourceTextFileBuffer.error.unsupported_encoding.message_arg= Character encoding \"{0}\" is not supported by this platform.
ResourceTextFileBuffer.error.closeReader= Could not close reader.

Back to the top