public static void action(File source,
File destination,
File xsl_examples,
File xsl_site) throws IOException {
if (".svn".equals(source.getName())) return;
System.out.print(source.getName());
if (source.isDirectory()) {
System.out.print(" ");
System.out.println(source.getCanonicalPath());
File dest = new File(destination, source.getName());
dest.mkdir();
File current;
File[] xmlFiles = source.listFiles();
if (xmlFiles != null) {
for (int i = 0; i < xmlFiles.length; i++) {
current = xmlFiles[i];
action(current, dest, xsl_examples, xsl_site);
}
}
else {
System.out.println("... skipped");
}
}
else if (source.getName().equals("index.xml")) {
System.out.println("... transformed");
convert(source, xsl_site, new File(destination, "index.php"));
File buildfile = new File(destination, "build.xml");
String path = buildfile.getCanonicalPath().substring(root.length());
path = path.replace(File.separatorChar, '/");
if ("/build.xml".equals(path)) return;
convert(source, xsl_examples, buildfile);
build.write("\t< ant antfile=\"${basedir}");
build.write(path);
build.write("\" target=\"install\" inheritAll=\"false\" / >\n");
}
else {
System.out.println("... skipped");
}
}
Inspects a file or directory that is given and performs the necessary actions on it (transformation or recursion). |