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

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

Introduction

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

Prototype

public Folder[] getFolders() 

Source Link

Document

Gets all folders in this folder, except "."

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();
    }//  w w  w  .  j a  va 2  s .co 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;
}