Changeset 4391


Ignore:
Timestamp:
2003-05-28T13:45:50+12:00 (21 years ago)
Author:
jmt12
Message:

Prevent a user from browsing the current open collection from the file system workspace, thus preventing one possibility of an infinite copy loop.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/file/FileNode.java

    r4386 r4391  
    66import javax.swing.filechooser.*;
    77import javax.swing.tree.*;
     8import org.greenstone.gatherer.Gatherer;
    89import org.greenstone.gatherer.file.FileFilter;
    910import org.greenstone.gatherer.file.FileSystemModel;
    1011import org.greenstone.gatherer.util.ArrayTools;
     12import org.greenstone.gatherer.util.Utility;
    1113
    1214public class FileNode
     
    233235    // Only map if there are no children.
    234236    if(children == null && file != null && getAllowsChildren()) {
    235                 ///ystem.err.println("Map: " + this);
     237        ///ystem.err.println("Map: " + this);
    236238        children = new ArrayList();
    237239        File[] files = file.listFiles();
     
    243245            files = tools.filter(files, filters[i].filter, filters[i].exclude);
    244246        }
     247        // If this node just happens to be the greenstone collection
     248        if(Gatherer.c_man != null && Gatherer.c_man.ready() && file.equals(new File(Utility.getCollectionDir(Gatherer.config.gsdl_path)))) {
     249            // Preclude the directory of any open collection
     250            String collection_name = Gatherer.c_man.getCollection().getName();
     251            for(int j = 0; collection_name != null && files != null && j < files.length; j++) {
     252            if(files[j].getName().equals(collection_name)) {
     253                // Remove the offending directory
     254                files = ArrayTools.remove(files, j);
     255                collection_name = null; // Only have to do this once.
     256            }
     257            }
     258        }
    245259        // Sort the remaining files.
    246260        tools.sort(files, true);
Note: See TracChangeset for help on using the changeset viewer.