Update of /cvsroot/fudaa/fudaa_devel/aide/src/prepro/template/task
In directory sc8-pr-cvs1:/tmp/cvs-serv12105/prepro/template/task
Added Files:
FileList.java
Log Message:
Ajout de la doc pour le prepro
--- NEW FILE: FileList.java ---
import java.util.*;
import java.io.*;
import java.util.Iterator;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.DirectoryScanner;
import org.apache.tools.ant.types.FileSet;
import org.apache.tools.ant.types.DirSet;
public class FileList extends Task {
protected Vector filesets= new Vector();
protected String file= null;
public FileList() {}
// The method executing the task
public void execute() throws BuildException {
DirectoryScanner s=new DirectoryScanner();
s.addDefaultExcludes();
s.setExcludes(new String[]{file});
for (int i= filesets.size()-1; i >=0 ; i--) {
DirSet fs= (DirSet)filesets.elementAt(i);
DirectoryScanner ds= fs.getDirectoryScanner(project);
File fromDir= fs.getDir(project);
String[] dirFiles= ds.getIncludedDirectories();
for (int j= dirFiles.length - 1; j >= 0; j--) {
File destFile=new File(fromDir,dirFiles[j]);
s.setBasedir(destFile);
s.scan();
writeListFile(destFile,s.getIncludedFiles());
}
}
}
private void writeListFile(File destDir,String[] filenames){
Writer out=null;
try {
out= new FileWriter(new File(destDir,file));
for (int j= filenames.length - 1; j >= 0; j--) {
out.write("<a href=\""+new File(destDir,filenames[j]).getAbsolutePath()+"\">"+filenames[j]+"</a>\n");
}
} catch (IOException _e) {}
finally{
if(out!=null){
try{
out.close();
}
catch(Exception e){
e.printStackTrace();
}
}
}
}
public void setFile(String _f) {
file=_f;
}
public void addDirset(DirSet set) {
filesets.addElement(set);
}
}
|