Deletes all files and subdirectories in directory (doesn't delete the directory
passed as parameter).
774170
public static boolean deleteContents(File directory) {
    File[] files = directory.listFiles();
    boolean success = true;
    if (files != null) {
      for (File file : files) {
        success &= deleteRecursively(file);
      }
    }
    return success;
  }
661303
protected function emptyDirectory($directory)
    {
        foreach ($this->doListContents($directory, true) as $path) {
            $this->deletePath($path);
        }
    }
1087594
def delete_directories(paths):
    
    for path in paths:
        if os.path.exists(path):
            shutil.rmtree(path)
1048298
public static boolean clearDirectory(File directory) {
		Assert.isTrue(directory.isDirectory(), "Parameter ist kein Verzeichnis");
		File[] files = directory.listFiles();
		boolean allDeleted = true;
		for (File file : files) {
			if (file.isDirectory()) {
				clearDirectory(file);
			}
			allDeleted &= file.delete();
		}

		return allDeleted;
	}
1114957
public function delete() : void
    {
        $files = $this->getFiles();
        foreach($files as $file) {
            $file->delete();
        }
        rmdir($this->path);
    }
238538
public function delete() {
		foreach ($this as $file) {
			if (!$file->isDot()) {
				$file->delete();
			}
		}

		if (!@rmdir($this->pathname)) {
			throw new FileException(sprintf('Failed to delete directory "%s"', $this->pathname));
		}
	}
1032
public static function deleteAllFilesInDirectory ($dir) {
        $dirIterator = new \RecursiveDirectoryIterator($dir, \FilesystemIterator::SKIP_DOTS);
        foreach (new \RecursiveIteratorIterator($dirIterator, \RecursiveIteratorIterator::CHILD_FIRST) as $file) {
            $file->isDir() ? rmdir($file) : unlink($file);
        }
    }
724602
def clean_directories(builddir, in_dir=True, out_dir=True):
    """"""
    container_in = local.path(builddir) / "container-in"
    container_out = local.path(builddir) / "container-out"

    if in_dir and container_in.exists():
        if ui.ask("Should I delete '{0}'?".format(container_in)):
            container_in.delete()
    if out_dir and container_out.exists():
        if ui.ask("Should I delete '{0}'?".format(container_out)):
            container_out.delete()
1219791
def cleanup(self):
        

        all([delete_file_or_tree(f) for f in self.to_delete])
        self.to_delete = []
944512
public static void deleteDirectory(File directory) throws IOException {
    if (!directory.exists()) {
      return;
    }

    if (!isSymlink(directory)) {
      cleanDirectory(directory);
    }

    if (!directory.delete()) {
      String message =
          "Unable to delete directory " + directory + ".";
      throw new IOException(message);
    }
  }
625494
public function delete()
    {
        // Deleting all children
        foreach ($this->getChildren() as $child) {
            $child->delete();
        }

        // Removing the directory itself
        rmdir($this->path);

        return true;
    }
544864
def clear(self):
        """"""
        for root, dirs, files in os.walk(self._root_dir, topdown=False):
            for file in files:
                os.unlink(os.path.join(root, file))
            os.rmdir(root)
        # Get the root dir back and re-initialise to start again
        root_dir = os.path.abspath(
            os.path.join(self._root_dir, os.pardir))
        self.__init__(root_dir)
258687
public static void deleteDirectorySilently(final File dir) {
    if (dir != null) {
      try {
        FileUtils.deleteDirectory(dir);
      } catch (final IOException e) {
        log.error("error when deleting dir {}", dir, e);
      }
    }
  }
702136
public static boolean deleteDirectory(final File dir) {
		boolean success = true;
		if (dir != null && dir.exists()) {
			try {
				if (dir.isDirectory()) {
					for (final File file : dir.listFiles()) {
						if(file == null) {
							return false;
						}
						if (!deleteDirectory(file)) {
							success = false;
							return success;
						}
					}
				}
				if (!dir.delete()) {
					success = false;
					return success;
				}
				return success;
			} catch (Exception e) {
				// Failed to delete files or directory
			}
		}
		return false;
	}
1228608
def remove_files(root_dir):
    
    for dirpath, dirnames, filenames in os.walk(os.path.abspath(root_dir)):
        for filename in filenames:
            os.remove(os.path.join(root_dir, filename))

        for dirname in dirnames:
            shutil.rmtree(os.path.join(root_dir, dirname))
15167
protected function cleanup()
    {
        if (is_dir($this->dir)) {
            // Recursively delete all files and folders.
            $files = new \RecursiveIteratorIterator(
                new \RecursiveDirectoryIterator($this->dir, \RecursiveDirectoryIterator::SKIP_DOTS),
                \RecursiveIteratorIterator::CHILD_FIRST
            );

            foreach ($files as $fileinfo) {
                if ($fileinfo->isDir()) {
                    rmdir($fileinfo->getRealPath());
                } else {
                    unlink($fileinfo->getRealPath());
                }
            }
            rmdir($this->dir);
            unset($this->git);
        }
    }
1098420
public static void delete(File file) throws IOException {

    if (file.isDirectory()) {

      // directory is empty, then delete it
      if (file.list().length == 0) {
        file.delete();
      } else {

        // list all the directory contents
        String files[] = file.list();

        for (String temp : files) {
          // construct the file structure
          File fileDelete = new File(file, temp);

          // recursive delete
          delete(fileDelete);
        }

        // check the directory again, if empty then delete it
        if (file.list().length == 0) {
          file.delete();
        }
      }

    } else {
      // if file, then delete it
      file.delete();
    }
  }