[Japi-cvs] SF.net SVN: japi:[795] tools/todoScanner/trunk/src/prj/net/sf/japi/tools/ todoScanner/T
Status: Beta
Brought to you by:
christianhujer
|
From: <chr...@us...> - 2009-02-09 02:09:37
|
Revision: 795
http://japi.svn.sourceforge.net/japi/?rev=795&view=rev
Author: christianhujer
Date: 2009-02-09 02:09:31 +0000 (Mon, 09 Feb 2009)
Log Message:
-----------
Added option to recurse.
Modified Paths:
--------------
tools/todoScanner/trunk/src/prj/net/sf/japi/tools/todoScanner/TodoScanner.java
Modified: tools/todoScanner/trunk/src/prj/net/sf/japi/tools/todoScanner/TodoScanner.java
===================================================================
--- tools/todoScanner/trunk/src/prj/net/sf/japi/tools/todoScanner/TodoScanner.java 2009-02-09 02:02:08 UTC (rev 794)
+++ tools/todoScanner/trunk/src/prj/net/sf/japi/tools/todoScanner/TodoScanner.java 2009-02-09 02:09:31 UTC (rev 795)
@@ -39,6 +39,9 @@
/** Lazy-initialized matcher. */
private Matcher matcher;
+ /** Whether to operate recursively. */
+ private boolean recursive;
+
/** Main program.
* @param args Command line arguments (try --help).
*/
@@ -63,6 +66,20 @@
matcher = null;
}
+ /** Sets to operate recursively. */
+ @Option({"r"})
+ public void setRecursive() {
+ setRecursive(true);
+ }
+
+ /** Sets whether or not to operate recursively.
+ * @param recursive whether or not to operate recursively.
+ */
+ @Option({"recursive"})
+ public void setRecursive(final boolean recursive) {
+ this.recursive = recursive;
+ }
+
/** {@inheritDoc} */
@SuppressWarnings({"InstanceMethodNamingConvention"})
public int run(@NotNull final List<String> args) throws Exception {
@@ -82,11 +99,22 @@
* @throws IOException In case of I/O problems.
*/
public void scanForTodos(@NotNull final File file) throws IOException {
- final InputStream in = new FileInputStream(file);
try {
- scanForTodos(in);
- } finally {
- in.close();
+ if (file.isDirectory() && recursive) {
+ for (final File entry : file.listFiles()) {
+ scanForTodos(entry);
+ }
+ }
+ if (file.isFile() || !recursive) {
+ final InputStream in = new FileInputStream(file);
+ try {
+ scanForTodos(in);
+ } finally {
+ in.close();
+ }
+ }
+ } catch (final IOException e) {
+ System.err.println("Error while reading " + file + ": " + e);
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|