Push current directory on directories stack when enter a sub-directory. Given directory is restored when child finishes,
using {@link #pop()} counterpart.

@param directory current directory.
765673
private void push(File directory) {
		// at this point file is guaranteed to be a directory
		stack.push(workingDirectory);
		workingDirectory = new Directory(directory);
		if (relativePath) {
			pathComponents.push(directory.getName());
		}
	}
811822
public function setDirectory($directory)
    {
        $this->directory = $directory . DIRECTORY_SEPARATOR . $this->id;
        if (file_exists($this->directory) === false) {
            mkdir($this->directory, $this->fileMode, true);
        }
    }
494321
@Override
        public void setDirectory(File dir) {
                if (dir == null) {
                        throw new BuildException("Cannot set null directory attribute.");
                }

                // no override
                if (this.directory == null) {
                        this.directory = new File(dir.getAbsolutePath());
                }
        }
1205062
public void setSourceDirectory (final File directory)
  {
    if (!directory.isAbsolute ())
    {
      throw new IllegalArgumentException ("source directory is not absolute: " + directory);
    }
    this.scanner.setBasedir (directory);
  }
145839
public static void recursivelyDeleteDirectory(File directory) throws IOException {
    if (!directory.exists()) {
      return;
    }
    checkArgument(directory.isDirectory(), "Cannot recursively delete a non-directory");
    walkFileTree(directory.toPath(), new DeletionFileVisitor());
  }
934139
INodeDirectory addToParent(byte[] localname,
                             INode newNode,
                             INodeDirectory parent,
                             boolean inheritPermission,
                             boolean propagateModTime,
                             int childIndex
                            ) throws FileNotFoundException {
    // insert into the parent children list
    newNode.name = localname;
    if(parent.addChild(newNode, inheritPermission, propagateModTime, childIndex) == null)
      return null;
    return parent;
  }
838830
public static void deleteDirectory(File directory) throws IOException {
    requireNonNull(directory, DIRECTORY_CAN_NOT_BE_NULL);
    deleteDirectoryImpl(directory.toPath());
  }
229254
public static boolean deleteDirectory(File dir)
    {

        if (dir.canWrite()) {
            File [] subFiles = dir.listFiles();

            for(int i=0; i<subFiles.length; i++) {
                if (subFiles[i].isDirectory())
                    deleteDirectory(subFiles[i]);
                else
                    subFiles[i].delete();
            }

        }

        return dir.delete();

    }
972495
public void setDirectory(final String directory) {
        this.directory = new File(this.configuration.getDirectory(), directory);
        if (!this.directory.exists()) {
            throw new IllegalArgumentException(String.format(
                    "Directory does not exist: %s.\n" +
                            "Configuration contained value %s which is supposed to be relative to " +
                            "configuration directory.",
                    this.directory, directory));
        }

        if (!this.directory.getAbsolutePath()
                .startsWith(this.configuration.getDirectory().getAbsolutePath())) {
            throw new IllegalArgumentException(String.format(
                    "All files and directories must be contained in the configuration directory the " +
                            "directory provided in the configuration breaks that contract: %s in config " +
                            "file resolved to %s.",
                    directory, this.directory));
        }
    }
1134284
protected final boolean tryCP(String directory){

		String[] cp = StringUtils.split(System.getProperty("java.class.path"), File.pathSeparatorChar);
		for(String s : cp){
			if(!StringUtils.endsWith(s, ".jar") && !StringUtils.startsWith(s, "/")){
				String path = s + File.separator + directory;
				File file = new File(path);
				if(this.testDirectory(file)==true){
					//found using class path
					try{
						this.url = file.toURI().toURL();
						this.file = file;
						this.fullDirectoryName = FilenameUtils.getPath(file.getAbsolutePath());
						this.setRootPath = directory;
						return true;
					}
					catch (MalformedURLException e) {
						this.errors.addError("init() - malformed URL for file with name " + this.file.getAbsolutePath() + " and message: " + e.getMessage());
					}
				}
			}
		}
		return false;
	}
790066
public void setDir(java.lang.String dir) {
        getStateHelper().put(PropertyKeys.dir, dir);
        handleAttribute("dir", dir);
    }
1221189
public static void directoryCheck(String dir) throws IOException {
		final File file = new File(dir);

		if (!file.exists()) {
			FileUtils.forceMkdir(file);
		}
	}
659456
static File validateDirectory(final File directory) {

        File newDirectory = null;

        try {
            newDirectory = AccessController.doPrivileged(new java.security.PrivilegedExceptionAction<File>() {
                @Override
                public File run() throws Exception {
                    boolean ok = true;

                    if (!directory.exists())
                        ok = directory.mkdirs() || directory.exists(); //2nd exists check is necessary to close timing window

                    if (!ok) {
                        Tr.error(tc, "UNABLE_TO_DELETE_RESOURCE_NOEX", new Object[] { directory.getAbsolutePath() });
                        return null;
                    }
                    return directory;
                }
            });
        } catch (PrivilegedActionException e) {
            Tr.error(tc, "UNABLE_TO_DELETE_RESOURCE", new Object[] { directory.getAbsolutePath(), e });
        }

        return newDirectory;
    }
395411
public void setWorkDir(String dir) throws IOException
    {
        File workDir = new File(dir);

        if (!workDir.exists() || !workDir.canWrite() || !workDir.canRead())
        {
            throw new IOException("Cannot access directory "+dir);
        }
        _workDir = workDir;
    }
542359
public void setCompileDirectory(String directory) {
        if (directory != null && directory.trim().length() > 0) {
            File file = new File(directory);
            if (file.exists() || file.mkdirs()) {
                this.compileDirectory = file;
            }
        }
    }
298865
public static void deleteDirectory(File root) {
        File[] currList;
        Stack<File> stack = new Stack<>();
        stack.push(root);
        while (!stack.isEmpty()) {
            if (stack.lastElement().isDirectory()) {
                currList = stack.lastElement().listFiles();
                if (currList != null && currList.length > 0) {
                    for (File curr : currList) {
                        stack.push(curr);
                    }
                } else {
                    stack.pop().delete();
                }
            } else {
                stack.pop().delete();
            }
        }
    }
1287474
public function add_dir($directory)
	{
		foreach ((array) $directory as $dir)
		{
			if ( ! preg_match('|.+/$|', $dir))
			{
				$dir .= '/';
			}

			$dir_time = $this->_get_mod_time($dir);
			$this->_add_dir($dir, $dir_time['file_mtime'], $dir_time['file_mdate']);
		}
	}