Collects files from a folder and all nested sub folders.

@param folder
Base folder for starting search
@param found
All found files will be added to this list
542280
private void collectFiles(final File folder, final List<File> found) {
		File[] files = folder.listFiles();
		if (files != null) {
			for (File file : files) {
				if (file.isDirectory()) {
					collectFiles(file, found);
				} else if (file.isFile() && file.getPath().endsWith(suffix)) {
					int index = 0;

					for (String text : plainTexts) {
						index = file.getPath().indexOf(text, index);
						if (index == -1) {
							break;
						} else {
							index += text.length();
						}
					}

					if (index >= 0) {
						found.add(file);
					}
				}
			}
		}
	}
251503
public void loadFolder(File folder) {
		// Remove previous files.
		LinearLayout root = this.chooser.getRootLayout();
		LinearLayout layout = (LinearLayout) root.findViewById(R.id.linearLayoutFiles);
		layout.removeAllViews();
		
		// Get the file path.
		if(folder == null || !folder.exists()) {
			if(defaultFolder != null) {
				this.currentFolder = defaultFolder;			
			} else {
				this.currentFolder = Environment.getExternalStorageDirectory();
			}
		} else {
			this.currentFolder = folder;
		}
		
		// Verify if the path exists.
		if(this.currentFolder.exists() && layout != null) {
			List<FileItem> fileItems = new LinkedList<FileItem>();
			
			// Add the parent folder.
			if(this.currentFolder.getParent() != null) {
				File parent = new File(this.currentFolder.getParent());
				if(parent.exists()) {
					fileItems.add(new FileItem(this.chooser.getContext(), parent, ".."));					
				}
			}
			
			// Verify if the file is a directory.
			if(this.currentFolder.isDirectory()) {
				// Get the folder's files.
				File[] fileList = this.currentFolder.listFiles();
				if(fileList != null) {
					// Order the files alphabetically and separating folders from files.
					Arrays.sort(fileList, new Comparator<File>() {
						public int compare(File file1, File file2) {
							if(file1 != null && file2 != null) {
								if(file1.isDirectory() && (!file2.isDirectory())) return -1;
								if(file2.isDirectory() && (!file1.isDirectory())) return 1;
								return file1.getName().compareTo(file2.getName());
							}
							return 0;
						}
					});		
					
					// Iterate all the files in the folder.
					for(int i=0; i<fileList.length; i++) {
						// Verify if file can be selected (is a directory or folder mode is not activated and the file pass the filter, if defined).
						boolean selectable = true;
						if(!fileList[i].isDirectory()) {
							selectable = !this.folderMode && (this.filter == null || fileList[i].getName().matches(this.filter));
						}
						
						// Verify if the file must be show.
						if(selectable || !this.showOnlySelectable) {
							// Create the file item and add it to the list.
							FileItem fileItem = new FileItem(this.chooser.getContext(), fileList[i]);
							fileItem.setSelectable(selectable);
							fileItems.add(fileItem);
						}
					}
				}
					
				// Set the name of the current folder.
				String currentFolderName = this.showFullPathInTitle? this.currentFolder.getPath() : this.currentFolder.getName();
				this.chooser.setCurrentFolderName(currentFolderName);
			} else {
				// The file is not a folder, add only this file.
				fileItems.add(new FileItem(this.chooser.getContext(), this.currentFolder));
			}
	
			
			// Add click listener and add the FileItem objects to the layout.
			for(int i=0; i<fileItems.size(); i++) {
				fileItems.get(i).addListener(this.fileItemClickListener);
				layout.addView(fileItems.get(i));
			}
			
			// Refresh default folder.
			defaultFolder = this.currentFolder;
		}			
	}
108803
private void createFolder(final StructrShellCommand parent, final Folder currentFolder, final String target) throws FrameworkException, IOException {

		final App app = StructrApp.getInstance();
		if (target.contains("/")) {

			final int lastSlashIndex      = target.lastIndexOf("/");
			final String targetFolderPath = target.substring(0, lastSlashIndex);
			final String targetFolderName = target.substring(lastSlashIndex + 1);
			final Folder parentFolder     = parent.findRelativeFolder(currentFolder, targetFolderPath);

			if (parentFolder != null) {

				checkAndCreateFolder(app, parent, parentFolder, targetFolderName);

			} else {

				term.println("Folder " + targetFolderPath + " does not exist");
			}

		} else {

			checkAndCreateFolder(app, parent, currentFolder, target);
		}
	}
1317321
public void uncheckFolders(Collection<String> folders) {

        for (String folder : folders) {
            CmsLazyTreeItem item = m_itemsByPath.get(folder);
            if ((item != null) && (item.getCheckBox() != null)) {
                item.getCheckBox().setChecked(false);
            }
        }
    }
444489
protected function set_search_dirty($folder)
    {
        if ($this->search_set && is_a($this->search_set, 'rcube_result_multifolder')) {
            if ($subset = $this->search_set->get_set($folder)) {
                $subset->incomplete = $this->search_set->incomplete = true;
            }
        }
    }
639660
private void listDirectory(File directory,
                               RelativeDirectory subdirectory,
                               Set<JavaFileObject.Kind> fileKinds,
                               boolean recurse,
                               ListBuffer<JavaFileObject> resultList) {
        File d = subdirectory.getFile(directory);
        if (!caseMapCheck(d, subdirectory))
            return;

        File[] files = d.listFiles();
        if (files == null)
            return;

        if (sortFiles != null)
            Arrays.sort(files, sortFiles);

        for (File f: files) {
            String fname = f.getName();
            if (f.isDirectory()) {
                if (recurse && SourceVersion.isIdentifier(fname)) {
                    listDirectory(directory,
                                  new RelativeDirectory(subdirectory, fname),
                                  fileKinds,
                                  recurse,
                                  resultList);
                }
            } else {
                if (isValidFile(fname, fileKinds)) {
                    JavaFileObject fe =
                        new RegularFileObject(this, fname, new File(d, fname));
                    resultList.append(fe);
                }
            }
        }
    }
126018
private void registerFolder(final Path folder) throws IOException {
        // register directory and sub-directories
        Files.walkFileTree(folder, new SimpleFileVisitor<Path>() {
            @Override
            public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs)
                    throws IOException
            {
                WatchKey key = dir.register(watcher, ENTRY_CREATE, ENTRY_DELETE, ENTRY_MODIFY);
                logger.debug("registering folder {}", dir);
                folders.put(key, dir);
                return FileVisitResult.CONTINUE;
            }
        });
    }
384819
public void setScreenshotFolder(final File folder) {
		this.directory = folder;
		boolean created = directory.mkdirs();
		LOG.info("Screenshot folder created succsessfully: " + created);
	}
1156640
public void addFolder(String folder) {

        m_searchObject.addFolder(folder);
        m_searchObjectChanged = true;
        ValueChangeEvent.fire(this, m_searchObject);
    }
534819
public void setSubfolder(String subfolder) {

        if (CmsStringUtil.isNotEmptyOrWhitespaceOnly(subfolder)) {
            m_subfolder = Boolean.valueOf(subfolder).booleanValue();
        }
    }
1324705
private function createBothFoldersInFileSystem(FileAbstraction $folder = null)
	{
		if ($folder instanceof File) {
			$folder = $folder->getParent();
		}

		$this->createFolderInFileSystem($this->getExternalPath(), $folder);
		$this->createFolderInFileSystem($this->getInternalPath(), $folder);
	}
314485
private void recursivelyCollectFolderTree(final List<ObjectInFolderContainer> list, final Folder child, final int maxDepth, final int depth, final Boolean includeAllowableActions) throws FrameworkException {

		if (depth > maxDepth) {
			return;
		}

		final CMISObjectInFolderWrapper wrapper                = new CMISObjectInFolderWrapper(includeAllowableActions);
		final ObjectInFolderContainerImpl impl                 = new ObjectInFolderContainerImpl();
		final List<ObjectInFolderContainer> childContainerList = new LinkedList<>();
		final String pathSegment                               = child.getName();

		impl.setObject(wrapper.wrapObjectData(wrapper.wrapGraphObject(child), pathSegment));
		impl.setChildren(childContainerList);

		// add wrapped object to current list
		list.add(impl);

		// fetch and sort children
		final List<Folder> children = Iterables.toList(child.getFolders());
		Collections.sort(children, new GraphObjectComparator(AbstractNode.name, false));

		// descend into children
		for (final Folder folderChild: children) {
			recursivelyCollectFolderTree(childContainerList, folderChild, maxDepth, depth+1, includeAllowableActions);
		}

	}
1000171
public void collect(Path file) throws IOException {
		Path targetPath = tempDir.resolve(projectRoot.relativize(file));
		Files.createDirectories(targetPath.getParent());
		Files.copy(file, targetPath);
	}
329101
public void mkdir(String folderName) {
    try {
      getDFS().mkdirs(new Path(this.path, folderName));
    } catch (IOException ioe) {
      ioe.printStackTrace();
    }
    doRefresh();
  }
453974
public static boolean containsFileRecursive(final File parent, final File search)
	{
		final File toSearch = search.getAbsoluteFile();
		boolean exists = false;
		final File[] children = parent.getAbsoluteFile().listFiles();
		if (children == null)
		{
			return false;
		}
		final List<File> fileList = Arrays.asList(children);
		for (final File currentFile : fileList)
		{
			if (currentFile.isDirectory())
			{
				exists = FileSearchExtensions.containsFileRecursive(currentFile, toSearch);
				if (exists)
				{
					return true;
				}
			}
			if (fileList.contains(toSearch))
			{
				return true;
			}
		}
		return exists;
	}
681500
public void addSourceFolder(File folder) {
		Assert.notNull(folder, "Folder must not be null");
		Assert.isTrue(!folder.isFile(), "Folder '" + folder + "' must not be a file");
		synchronized (this.monitor) {
			checkNotStarted();
			this.folders.put(folder, null);
		}
	}
163312
private void listFolder(final StructrShellCommand parent, final Iterable<AbstractFile> folder) throws FrameworkException, IOException {

		boolean hasContents = false;

		for (final AbstractFile child : folder) {

			if (parent.isAllowed(child, Permission.read, false)) {

				hasContents = true;

				if (child instanceof Folder) {

					term.setBold(true);
					term.setTextColor(4);
					term.print(child.getName() + "  ");
					term.setTextColor(7);
					term.setBold(false);

				} else {

					term.print(child.getName() + "  ");
				}
			}
		}

		if (hasContents) {
			term.println();
		}
	}