deleted: export="true"
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / batch / FileFinder.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
3  * All rights reserved. This program and the accompanying materials 
4  * are made available under the terms of the Common Public License v0.5 
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v05.html
7  * 
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  ******************************************************************************/
11 package net.sourceforge.phpdt.internal.compiler.batch;
12
13 import java.io.File;
14
15 public class FileFinder {
16         private final int INITIAL_SIZE = 10;
17         public String[] resultFiles = new String[INITIAL_SIZE];
18         public int counter = 0;
19 public void find(File f, String pattern, boolean verbose) {
20         if (verbose) {
21                 System.out.println(Main.bind("scanning.start",f.getAbsolutePath())); //$NON-NLS-1$
22         }
23         find0(f, pattern, verbose);
24         System.arraycopy(resultFiles, 0, (resultFiles = new String[counter]), 0, counter);
25 }
26 public void find0(File f, String pattern, boolean verbose) {
27         if (f.isDirectory()) {
28                 String[] files = f.list();
29                 if (files == null) return;
30                 for (int i = 0, max = files.length; i < max; i++) {
31                         File current = new File(f, files[i]);
32                         if (current.isDirectory()) {
33                                 find0(current, pattern, verbose);
34                         } else {
35                                 if (current.getName().toUpperCase().endsWith(pattern)) {
36                                         int length;
37                                         if ((length = resultFiles.length) == counter) {
38                                                 System.arraycopy(resultFiles, 0, (resultFiles = new String[length * 2]), 0, length);
39                                         }
40                                         resultFiles[counter++] = current.getAbsolutePath();
41                                         if (verbose && (counter % 100) == 0)
42                                                 System.out.print('.');
43                                 }
44                         }
45                 }
46         }
47 }
48 }