Example usage for org.apache.wicket.util.file Folder getFiles

List of usage examples for org.apache.wicket.util.file Folder getFiles

Introduction

In this page you can find the example usage for org.apache.wicket.util.file Folder getFiles.

Prototype

public File[] getFiles() 

Source Link

Usage

From source file:org.artifactory.common.wicket.component.file.path.PathHelper.java

License:Open Source License

public List<File> getFiles(String path, PathMask mask) {
    String absolutePath = getAbsolutePath(path);
    Folder folder = new Folder(getPathFolder(absolutePath));

    if (!folder.exists() || !folder.isDirectory()) {
        return Collections.emptyList();
    }/*from   w  ww.  ja  v  a2  s  .  c o  m*/

    if (!isParentOf(workingDirectoryPath, folder)) {
        return Collections.emptyList();
    }
    Folder[] folders = folder.getFolders();
    File[] files = folder.getFiles();
    List<File> filesList = new ArrayList<>(folders.length + files.length);

    if (mask.includeFolders()) {
        for (Folder file : folders) {
            String fileAbsPath = file.getAbsolutePath().replace('\\', '/');
            if (startsWithIgnoreCase(fileAbsPath, absolutePath)) {
                filesList.add(file);
            }
        }
    }

    if (mask.includeFiles()) {
        for (File file : files) {
            String fileAbsPath = file.getPath().replace('\\', '/');
            if (startsWithIgnoreCase(fileAbsPath, absolutePath)) {
                filesList.add(file);
            }
        }
    }
    return filesList;
}