Adding phpdoc tags to String[] array so the code scanner will pick them up and do...
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / batch / FileFinder.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2004 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials 
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.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 static final int INITIAL_SIZE = 10;
17
18         public String[] resultFiles = new String[INITIAL_SIZE];
19
20         public int count = 0;
21
22         public void find(File f, String pattern, boolean verbose) {
23                 if (verbose) {
24                         // System.out.println(Main.bind("scanning.start",f.getAbsolutePath()));
25                         // //$NON-NLS-1$
26                 }
27                 find0(f, pattern, verbose);
28                 System.arraycopy(this.resultFiles, 0,
29                                 (this.resultFiles = new String[this.count]), 0, this.count);
30         }
31
32         public void find0(File f, String pattern, boolean verbose) {
33                 if (f.isDirectory()) {
34                         String[] files = f.list();
35                         if (files == null)
36                                 return;
37                         for (int i = 0, max = files.length; i < max; i++) {
38                                 File current = new File(f, files[i]);
39                                 if (current.isDirectory()) {
40                                         find0(current, pattern, verbose);
41                                 } else {
42                                         if (current.getName().toUpperCase().endsWith(pattern)) {
43                                                 int length;
44                                                 if ((length = this.resultFiles.length) == this.count) {
45                                                         System
46                                                                         .arraycopy(
47                                                                                         this.resultFiles,
48                                                                                         0,
49                                                                                         (this.resultFiles = new String[length * 2]),
50                                                                                         0, length);
51                                                 }
52                                                 this.resultFiles[this.count++] = current
53                                                                 .getAbsolutePath();
54                                                 if (verbose && (this.count % 100) == 0)
55                                                         System.out.print('.');
56                                         }
57                                 }
58                         }
59                 }
60         }
61 }