Search in sources :

Example 1 with FileDirectoryEntry

use of com.thoughtworks.go.domain.FileDirectoryEntry in project gocd by gocd.

the class DirectoryReader method listEntries.

/**
     * Recursively builds a tree of the specified rootFolder
     * TODO: ChrisS : Note that the URL stuff is completely wrong and should NOT be here - that is view, this is model
     */
public DirectoryEntries listEntries(File rootFolder, String relativePath) {
    DirectoryEntries entries = new DirectoryEntries();
    if (rootFolder == null) {
        return entries;
    }
    File[] files = rootFolder.listFiles(VISIBLE_NON_SERIALIZED_FILES);
    if (files == null) {
        return entries;
    }
    Arrays.sort(files, new FileComparator());
    for (File file : files) {
        String name = file.getName();
        String url = getUrl(relativePath, name);
        entries.add(file.isDirectory() ? new FolderDirectoryEntry(name, url, listEntries(file, getCurrentPath(relativePath) + name)) : new FileDirectoryEntry(name, url));
    }
    return entries;
}
Also used : FolderDirectoryEntry(com.thoughtworks.go.domain.FolderDirectoryEntry) DirectoryEntries(com.thoughtworks.go.domain.DirectoryEntries) FileDirectoryEntry(com.thoughtworks.go.domain.FileDirectoryEntry) File(java.io.File)

Aggregations

DirectoryEntries (com.thoughtworks.go.domain.DirectoryEntries)1 FileDirectoryEntry (com.thoughtworks.go.domain.FileDirectoryEntry)1 FolderDirectoryEntry (com.thoughtworks.go.domain.FolderDirectoryEntry)1 File (java.io.File)1