From e8ca55189ba046c09f8ac74c3c83c34f132585d1 Mon Sep 17 00:00:00 2001 From: David McKnight Date: Tue, 11 Nov 2008 15:29:43 +0000 Subject: [PATCH] [241327] IRemoteFile.getParentName returns null for ssh, ftp, dstore, and local --- .../core/servicesubsystem/AbstractRemoteFile.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/servicesubsystem/AbstractRemoteFile.java b/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/servicesubsystem/AbstractRemoteFile.java index 14d5a3121c4..a1cbc3be1eb 100644 --- a/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/servicesubsystem/AbstractRemoteFile.java +++ b/rse/plugins/org.eclipse.rse.subsystems.files.core/src/org/eclipse/rse/subsystems/files/core/servicesubsystem/AbstractRemoteFile.java @@ -170,9 +170,16 @@ public abstract class AbstractRemoteFile extends RemoteFile */ public String getParentName() { - String parentPath = getParentPath(); - String parentName = getNameFromPath(parentPath); - return parentName; + if (_parentFile != null) // optimization if we have the parentFile + return _parentFile.getName(); // if we had used getParentFile(), the operation may have been more + // expensive than just using the parent path + else { + String parentPath = getParentPath(); + if (parentPath == null) // parentPath may be null - avoid NPE + return null; + else + return getNameFromPath(parentPath); + } } /**