diff --git a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/persistence/PFMetadataLocation.java b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/persistence/PFMetadataLocation.java index 2269f9fa90c..13fe970184a 100644 --- a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/persistence/PFMetadataLocation.java +++ b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/persistence/PFMetadataLocation.java @@ -49,6 +49,7 @@ class PFMetadataLocation implements PFPersistenceLocation { public PFPersistenceLocation[] getChildren() { File[] members = _baseFolder.listFiles(); + if (members == null) members = new File[0]; List children = new ArrayList(members.length); for (int i = 0; i < members.length; i++) { File member = members[i]; @@ -87,6 +88,7 @@ class PFMetadataLocation implements PFPersistenceLocation { public void keepChildren(Set keepSet) { File[] children = _baseFolder.listFiles(); + if (children == null) children = new File[0]; for (int i = 0; i < children.length; i++) { File child = children[i]; if (!keepSet.contains(child.getName())) { @@ -96,6 +98,7 @@ class PFMetadataLocation implements PFPersistenceLocation { } public void setContents(InputStream stream) { + ensure(); OutputStream out = null; try { out = new FileOutputStream(getContentsFile()); @@ -130,14 +133,16 @@ class PFMetadataLocation implements PFPersistenceLocation { * @param file the file to delete. */ private void deleteFile(File file) { - if (file.isDirectory()) { - File[] children = file.listFiles(); - for (int i = 0; i < children.length; i++) { - File child = children[i]; - deleteFile(child); + if (file.exists()) { + if (file.isDirectory()) { + File[] children = file.listFiles(); + for (int i = 0; i < children.length; i++) { + File child = children[i]; + deleteFile(child); + } } + file.delete(); } - file.delete(); } private File getContentsFile() { diff --git a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/persistence/PFPersistenceLocation.java b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/persistence/PFPersistenceLocation.java index bc4be695353..32d1afb754f 100644 --- a/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/persistence/PFPersistenceLocation.java +++ b/rse/plugins/org.eclipse.rse.core/src/org/eclipse/rse/internal/persistence/PFPersistenceLocation.java @@ -42,7 +42,8 @@ interface PFPersistenceLocation { /** * @return the locations of the children of this location. It is possible - * for a location to have both contents and children. + * for a location to have both contents and children. Since this location + * is a handle it may not exist, in which case this returns an empty array. */ PFPersistenceLocation[] getChildren(); @@ -63,6 +64,7 @@ interface PFPersistenceLocation { /** * Keeps only those children from this location that are in the keep set. * Typically used to clean renamed nodes from the tree on a save operation. + * If the location does not yet exist, this does nothing. * @param keepSet The names of the children that should be kept. Others are discarded. */ void keepChildren(Set keepSet); @@ -70,6 +72,7 @@ interface PFPersistenceLocation { /** * Sets the contents of this location to a particular stream. * Implementations must close this stream when finished. + * This forces the location to come into existence if it does not already exist. * @param stream the stream from which to read the new contents of this location. */ void setContents(InputStream stream); @@ -77,6 +80,7 @@ interface PFPersistenceLocation { /** * Returns an open stream which can be read to retrieve the contents of this * location. The client is responsible for closing this stream. + * If the location does not yet exist this will return null and log the attempt. * @return a stream that will retrieve the contents of this location. */ InputStream getContents();