X-Git-Url: http://git.phpeclipse.com diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/batch/FileFinder.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/batch/FileFinder.java index 0b842c8..aa8ab54 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/batch/FileFinder.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/batch/FileFinder.java @@ -1,48 +1,61 @@ /******************************************************************************* - * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others. + * Copyright (c) 2000, 2004 IBM Corporation and others. * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v0.5 + * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v05.html + * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM Corporation - initial API and implementation - ******************************************************************************/ + *******************************************************************************/ package net.sourceforge.phpdt.internal.compiler.batch; import java.io.File; public class FileFinder { - private final int INITIAL_SIZE = 10; + private static final int INITIAL_SIZE = 10; + public String[] resultFiles = new String[INITIAL_SIZE]; - public int counter = 0; -public void find(File f, String pattern, boolean verbose) { - if (verbose) { - System.out.println(Main.bind("scanning.start",f.getAbsolutePath())); //$NON-NLS-1$ + + public int count = 0; + + public void find(File f, String pattern, boolean verbose) { + if (verbose) { + // System.out.println(Main.bind("scanning.start",f.getAbsolutePath())); + // //$NON-NLS-1$ + } + find0(f, pattern, verbose); + System.arraycopy(this.resultFiles, 0, + (this.resultFiles = new String[this.count]), 0, this.count); } - find0(f, pattern, verbose); - System.arraycopy(resultFiles, 0, (resultFiles = new String[counter]), 0, counter); -} -public void find0(File f, String pattern, boolean verbose) { - if (f.isDirectory()) { - String[] files = f.list(); - if (files == null) return; - for (int i = 0, max = files.length; i < max; i++) { - File current = new File(f, files[i]); - if (current.isDirectory()) { - find0(current, pattern, verbose); - } else { - if (current.getName().toUpperCase().endsWith(pattern)) { - int length; - if ((length = resultFiles.length) == counter) { - System.arraycopy(resultFiles, 0, (resultFiles = new String[length * 2]), 0, length); + + public void find0(File f, String pattern, boolean verbose) { + if (f.isDirectory()) { + String[] files = f.list(); + if (files == null) + return; + for (int i = 0, max = files.length; i < max; i++) { + File current = new File(f, files[i]); + if (current.isDirectory()) { + find0(current, pattern, verbose); + } else { + if (current.getName().toUpperCase().endsWith(pattern)) { + int length; + if ((length = this.resultFiles.length) == this.count) { + System + .arraycopy( + this.resultFiles, + 0, + (this.resultFiles = new String[length * 2]), + 0, length); + } + this.resultFiles[this.count++] = current + .getAbsolutePath(); + if (verbose && (this.count % 100) == 0) + System.out.print('.'); } - resultFiles[counter++] = current.getAbsolutePath(); - if (verbose && (counter % 100) == 0) - System.out.print('.'); } } } } } -}