protected void scanDir()

in java/src/org/apache/qetest/xsl/ResultScanner.java [106:185]


    protected void scanDir(File resultDir, PrintWriter writer, int depth)
            throws Exception
    {
        depth++;
        if (depth > MAX_DEPTH)
        {
            logError(writer, "scanDir: MAX_DEPTH exceeded, returning!");
            return;
        }

        if (!resultDir.exists() || !resultDir.isDirectory())
        {
            logError(writer, "scanDir: attempt to scan non-directory, returning!");
            return;
        }
        
        // Get list of teststatus files that definitely have problems
        String badResults[] = resultDir.list(
                new FilenameFilter() // anonymous class
                {
                    public boolean accept(File dir, String name)
                    {
                        // Shortcuts for bogus filenames and dirs
                        if (name == null || dir == null)
                            return false;
                        // Skip already-rolledup Harness reports
                        if (name.endsWith("Harness.xml"))
                            return false;
                        return (name.startsWith("Fail-") 
                                || name.startsWith("Errr-") 
                                || name.startsWith("Incp-"));
                    }
                }
            );

        // Get list of teststatus files that passed or were 
        //  ambiguous, which means they didn't fail
        String okResults[] = resultDir.list(
                new FilenameFilter() // anonymous class
                {
                    public boolean accept(File dir, String name)
                    {
                        // Shortcuts for bogus filenames and dirs
                        if (name == null || dir == null)
                            return false;
                        return (name.startsWith("Pass-") 
                                || name.startsWith("Ambg-"));
                    }
                }
            );

        // Output references to both sets of files if needed
        if ((null != okResults) && (null != badResults)
            && (okResults.length + badResults.length > 0))
        {
            logTestGroup(writer, resultDir.getPath(), okResults, badResults);
        }
        
        // Traverse down directories
        String subdirs[] = resultDir.list(
                new FilenameFilter() // anonymous class
                {
                    public boolean accept(File dir, String name)
                    {
                        // Shortcuts for bogus filenames and dirs and CVS junk
                        if (null == name || null == dir || "CVS".equals(name))
                            return false;
                        return (new File(dir, name)).isDirectory();
                    }
                }
            );
        if (null != subdirs)
        {
            for (int i=0; i < subdirs.length; i++)
            {
                scanDir(new File(resultDir, subdirs[i]), writer, depth + 1);
            }
        }

    }