public File[] getFiles(File dir, boolean useFileHiding) {
try {
String filenames[] = null;
WebdavFile files[] = null;
HttpURL url = null;
String path = null;
String localDir = null;
this.connect();
// Now we try to list files
path = dir.getPath();
//System.out.println("getFiles : RAW PATH : '" + path + "'");
// If path contains the server preamble, we need to extract that
// and have the path only
if (path.startsWith("http")) {
//System.out.println("getFiles : preample : " + this.uri);
path = path.replaceAll(this.uri, "");
}
if (!path.endsWith("/")) {
path = path + "/";
}
//System.out.println("getFiles : path : " + path);
this.webdavResource.setPath(path);
filenames = this.webdavResource.list();
files = new WebdavFile[filenames.length];
for (int i = 0; i < filenames.length; i++) {
//System.out.println("file : " + filenames[i]);
// Lets try to construct a uri from the dir
// given and the current file
localDir = dir.getPath();
if (!localDir.endsWith("/")) localDir = localDir + "/";
String filepath = localDir + filenames[i];
//System.out.println("getFiles : file fullpath : " + filepath);
url = this.uriToHttpURL(filepath);
// Need to add user info so has access for queries
url.setUserinfo(username, password);
files[i] = new WebdavFile(url, this.rootURL);
}
return files;
} catch (Exception e) {
System.err.println(e.toString());