aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSafey A.Halim <safey.allah@gmail.com>2010-10-28 17:38:58 +0000
committerSafey A.Halim <safey.allah@gmail.com>2010-10-28 17:38:58 +0000
commit6789d36f3d5e226c39457e36fc6c6887ead826d1 (patch)
tree1919898de96bc46cb3507c86ff783662b59d3d6d /src
parent4f7e2fa38eab56d0e084e86204b88c7bbecd8cbd (diff)
downloadgnunet-6789d36f3d5e226c39457e36fc6c6887ead826d1.tar.gz
gnunet-6789d36f3d5e226c39457e36fc6c6887ead826d1.zip
Improving Seaspider's recursive method.
Diffstat (limited to 'src')
-rw-r--r--src/monkey/seaspider/org/gnunet/seaspider/Seaspider.java32
1 files changed, 15 insertions, 17 deletions
diff --git a/src/monkey/seaspider/org/gnunet/seaspider/Seaspider.java b/src/monkey/seaspider/org/gnunet/seaspider/Seaspider.java
index 0c1968eaf..c9b54c6d5 100644
--- a/src/monkey/seaspider/org/gnunet/seaspider/Seaspider.java
+++ b/src/monkey/seaspider/org/gnunet/seaspider/Seaspider.java
@@ -65,28 +65,24 @@ public class Seaspider {
65 } 65 }
66 66
67 67
68 private static void parseRecursively(String dirPath) 68 private static void parseRecursively(String path)
69 { 69 {
70 File dir = new File(dirPath); 70 File file = new File(path);
71 71
72 if (!dir.isDirectory()) { 72 if (!file.isDirectory()) {
73 if (dirPath.endsWith(".c")) { 73 if (path.endsWith(".db"))
74 doParseFile(dirPath);
75 return;
76 } else /* Probably the Database file */
77 return; 74 return;
75 /* A source file */
76 doParseFile(path);
77 return;
78 } 78 }
79 79
80 System.out.println("Reading from: " + dirPath + " source directory..."); 80 /* A source directory */
81 String[] dirContents = dir.list(filter);/* Only directories and .c files */ 81 System.out.println("Reading from: " + path + " source directory...");
82 String[] dirContents = file.list(filter);/* Only directories and .c files */
82 for (int i = 0; i < dirContents.length; i++) { 83 for (int i = 0; i < dirContents.length; i++) {
83 String fullPath = dirPath + "/" + dirContents[i]; 84 String fullPath = path + "/" + dirContents[i];
84 File file = new File(fullPath); 85 parseRecursively(fullPath);
85
86 if (file.isDirectory())
87 parseRecursively(fullPath);
88 else
89 doParseFile(fullPath); /* Path is for a file */
90 } 86 }
91 } 87 }
92 88
@@ -109,8 +105,10 @@ public class Seaspider {
109 /* Should be a valid path for a file or a directory */ 105 /* Should be a valid path for a file or a directory */
110 File file = new File(args[i]); 106 File file = new File(args[i]);
111 if (!file.exists()) { 107 if (!file.exists()) {
112 System.err.println("\"" + args[i]+ "\" is an invalid file or directory location"); 108 System.err.println("\"" + args[i] + "\" is an invalid file or directory location");
113 System.exit(1); 109 System.exit(1);
110 } else if (!file.isDirectory() && !args[i].endsWith(".c")) {
111 System.err.println("\"" + args[i] + "\" only source files can be parsed");
114 } 112 }
115 } 113 }
116 } 114 }