Arbeitsstand Anfang Februar
git-svn-id: https://brutex.net/svn/xservices/trunk@107 e7e49efb-446e-492e-b9ec-fcafc1997a86tag-20130205r
parent
031359ae1f
commit
159661d202
|
@ -1,47 +0,0 @@
|
|||
package net.brutex.xservices.types;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
@XmlRootElement
|
||||
public class FileInfoListType {
|
||||
|
||||
private List<FileInfoType> list = new ArrayList<FileInfoType>();
|
||||
|
||||
public void setDirectory(File dir, final boolean withDirectories, final boolean withFiles, int depth) {
|
||||
if(depth <=0) return;
|
||||
|
||||
File[] files = dir.listFiles(new FileFilter() {
|
||||
|
||||
public boolean accept(File pathname) {
|
||||
if(!withFiles && !pathname.isFile()) return false;
|
||||
return true;
|
||||
}
|
||||
});
|
||||
if(files==null) return;
|
||||
for( File e : files) {
|
||||
if(e.isDirectory()) setDirectory(e, withDirectories, withFiles, depth-1);
|
||||
if( (withDirectories && e.isDirectory())
|
||||
|| withFiles && e.isFile()) {
|
||||
this.list.add(new FileInfoType(e));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setDirectory(String dir, final boolean withDirectories, final boolean withFiles, int depth) {
|
||||
setDirectory( (new File(dir)), withDirectories, withFiles, depth);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@XmlElement(name="FileInfoList")
|
||||
public List<FileInfoType> getFiles() {
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue