summaryrefslogtreecommitdiffstats
path: root/conversion/ConvertDirectory.java
diff options
context:
space:
mode:
authorrsiddharth <rsiddharth@ninthfloor.org>2012-06-23 22:44:40 +0530
committerrsiddharth <rsiddharth@ninthfloor.org>2012-06-23 22:44:40 +0530
commit8bcd7f58acd38f5d5e1731f89be4a10a79d0fdb7 (patch)
tree6c1d4dfc97d77230ecf95d4e0f8b4fe1cde5b739 /conversion/ConvertDirectory.java
scruf is "bzr"ed now.
Diffstat (limited to 'conversion/ConvertDirectory.java')
-rw-r--r--conversion/ConvertDirectory.java40
1 files changed, 40 insertions, 0 deletions
diff --git a/conversion/ConvertDirectory.java b/conversion/ConvertDirectory.java
new file mode 100644
index 0000000..063bd87
--- /dev/null
+++ b/conversion/ConvertDirectory.java
@@ -0,0 +1,40 @@
+package scruf.conversion;
+
+import java.io.*;
+import scruf.index.*;
+
+public class ConvertDirectory {
+ private ConvertFile html;
+ private CanConvert canConvert;
+ private boolean can;
+ public ConvertDirectory() {
+ html = new ConvertFile();
+ canConvert = new CanConvert();
+ }
+ public void convert(File directory) {
+ if(!directory.isDirectory()) {
+ System.out.println(directory+" is not a Directory."+
+ " No conversion done on.");
+ return;
+ }
+ // index creator for the present directory.
+ IndexCreator index = new IndexCreator(directory);
+ // iterate through the directory.
+ for(File file:directory.listFiles(new FileSieve())) {
+ if(file.isFile()) {
+ can = canConvert.check(file);
+ if(can) {
+ html.convert(file);
+ index.add(file);
+ }
+ }
+ else if(file.isDirectory()) {
+ this.convert(file);
+ }
+ }
+
+ boolean modified = index.write();
+ if(modified)
+ html.convert(index.indexFile());
+ }
+} \ No newline at end of file