FileDocCategorySizeDatePackage
FileLister.javaAPI DocGlassfish v2 API3833Fri Jun 15 00:35:14 BST 2007com.sun.enterprise.util.io

FileLister

public abstract class FileLister extends Object
author
bnevins
version

Fields Summary
private ArrayList
fileList
private File
mainRoot
private boolean
copySymLinks
private boolean
copyEmptyDirs
Constructors Summary
FileLister(File root)

        mainRoot = root;
        fileList = new ArrayList();
    
Methods Summary
public java.lang.String[]getFiles()

        getFilesInternal(mainRoot);
        String[] files = new String[fileList.size()];
        
        if(files.length <= 0)
            return files;
        
        int len = 0;
        
        if(relativePath())
            len = mainRoot.getPath().length() + 1;
        
        for(int i = 0; i < files.length; i++)
        {
            files[i] = ((File)fileList.get(i)).getPath().substring(len).replace('\\", '/");
        }
        
        Arrays.sort(files, String.CASE_INSENSITIVE_ORDER);
        return files;
    
public voidgetFilesInternal(java.io.File root)

        File[] files = root.listFiles();
        
        if(files.length <= 0 && copyEmptyDirs)
            fileList.add(root);

        for(int i = 0; i < files.length; i++)
        {
            if(files[i].isDirectory())
            {
                if(!copySymLinks && !FileUtils.safeIsRealDirectory(files[i]))
                    continue;
                
                getFilesInternal(files[i]);
            }
            else
                fileList.add(files[i]);	// actual file
        }
    
protected abstract booleanrelativePath()

public voidsetCopyEmptyDirs(boolean b)

        copyEmptyDirs = b;
    
public voidsetCopySymLinks(boolean b)

        copySymLinks = b;