Deletes a file or a directory.

@param string $dir The source's name
@param string $path The file|directory's path
@param string $name The file|directory's name
@param string $type The type (file|dir)
@return array|bool
160776
public function delete($dir, $path, $name, $type = 'file'){
    if ( ($cfg = $this->dir($dir)) &&
      ($root = $this->get_root_path($dir))
    ){
      $is_file = $type === 'file';
      $wtype = $is_file ? 'file' : 'directory';
      $delete = [];
      if ( !empty($cfg['tabs']) ){
        foreach ( $cfg['tabs'] as $t ){
          if ( empty($t['fixed']) ){
            $real = $root . $t['path'];
            if ( dirname($path) !== '.' ){
              $real .= dirname($path) . '/';
            }
            if ( $is_file ){
              foreach ( $t['extensions'] as $e ){
                $tmp = $real . $name . '.' . $e['ext'];
                if ( file_exists($tmp) && !\in_array($tmp, $delete) ){
                  array_push($delete, $tmp);
                  if ( $t['url'] === 'php' ){
                    $del_perm = $tmp;
                  }
                }
              }
            }
            else {
              $real .= $name;
              if ( file_exists($real) && !\in_array($real, $delete) ){
                array_push($delete, $real);
                if ( $t['url'] === 'php' ){
                  $del_perm = $real;
                }
              }
            }
          }
        }
      }
      else {
        $real = $root . $path;
        if ( file_exists($real) ){
          array_push($delete, $real);
        }
      }
      $files = [];
      // Remove permissions
      if ( !empty($del_perm) ){
        $this->delete_perm($del_perm, $type);
      }
      foreach ( $delete as $d ){
        if ( $is_file ){
          // Add it to files to be closed
          array_push($files, $this->real_to_url($d));
          // Delete file
          if ( !unlink($d) ){
            $this->error("Impossible to delete the file $d");
            return false;
          }
          // Remove file's options
          $this->options->remove($this->options->from_code($this->real_to_id($d), $this->_files_pref()));
        }
        else {
          $f = $this->rem_dir_opt($d);
          $files = array_merge($files, $f);
          // Delete directory
          if ( !bbn\file\dir::delete($d) ){
            $this->error("Impossible to delete the directory $d");
            return false;
          }
        }
      }
      return ['files' => $files];
    }
    return false;
  }
830062
public function file($path, $type = 'debug')
    {
        $this->pushHandler(new StreamHandler($path, $this->getLevel($type)));
    }
480729
private static function deleteDirectory($path = '')
    {
        $directory = dir($path);
        while (($item = $directory->read()) !== false) {
            if ($item == '.' || $item == '..') {
                continue;
            }
            $file = $directory->path . '/' . $item;
            if (is_dir($file)) {
                self::deleteDirectory($file);
                continue;
            }
            unlink($file);
        }
        $directory->close();
        rmdir($path);
    }
1293813
private function deleteFiles(Directory $path)
    {
        foreach ($this->manager->findFiles($path) as $file) {
            $this->wrapper->delete($file->getRealpath());
        }
    }
98810
private function ignoreItem($type, $name, $ignore)
    {
        if ($type == 'file' && in_array(pathinfo($name, PATHINFO_EXTENSION), $ignore)) {
            return true;
        } elseif ($type == 'dir' && in_array($name, $ignore)) {
            return true;
        }
        return false;
    }
121616
public static function deleteFolder($dir)
    {
        $dh = @opendir($dir);
        if (!$dh) {
            return false;
        }
        while (false !== ($file = readdir($dh))) {
            if (($file != '.') && ($file != '..')) {
                $full = $dir . '/' . $file;
                if (is_dir($full)) {
                    self::deleteFolder($full);
                } else {
                    unlink($full);
                }
            }
        }
        closedir($dh);
        rmdir($dir);
        return true;
    }
173970
public static boolean deleteDir(File dir) {
		if (dir != null && dir.isDirectory()) {
			String[] children = dir.list();
			for (int i = 0; i < children.length; i++) {
				if (!deleteDir(new File(dir, children[i])))
					return false;
			}
		}
		return dir.delete();
	}
469296
private static function FilterByType($dir, $file, FileSystemEntryType $type = null)
    {
        if ($file == '.' || $file == '..')
            return false;
        
        if (!$type)
            return true;
        
        $path = Path::Combine($dir, $file);
        
        
        switch ($type)
        {
            case FileSystemEntryType::File():
                return is_file($path);
                
            case FileSystemEntryType::Folder():
                return is_dir($path);
                
            case FileSystemEntryType::Link():
                return is_link($path);
        }
        return false;
    }
1048201
private function createDirectory($path = '', $name = '')
    {
        $directory = new ArrayObject();
        $directory['name'] = $name;
        $directory['real_path'] = $path;
        $directory['directories'] = [];
        $directory['files'] = [];

        return $directory;
    }
802889
public function dirDelete($dir)
    {
        $dir = $this->alias->resolve($dir);

        if (!is_dir($dir)) {
            return;
        }

        $this->_dirDelete($dir);
    }
892703
public static function deleteFolder($dirPath)
    {
        $it = new RecursiveDirectoryIterator($dirPath, RecursiveDirectoryIterator::SKIP_DOTS);
        $files = new RecursiveIteratorIterator(
            $it,
            RecursiveIteratorIterator::CHILD_FIRST
        );
        foreach ($files as $file) {
            if ($file->isDir()) {
                rmdir($file->getRealPath());
            } else {
                unlink($file->getRealPath());
            }
        }
        rmdir($dirPath);
    }
278829
public function deleteDirectoryContents($path)
    {
        $dir = new \RecursiveDirectoryIterator($path);
        $iterator = new \RecursiveIteratorIterator($dir, \RecursiveIteratorIterator::CHILD_FIRST);

        /** @var \SplFileInfo $object */
        foreach ($iterator as $object) {
            if (!in_array($object->getBasename(), ['.', '..'])) {
                if ($object->isLink() || $object->isFile()) {
                    unlink($object->getPathname());
                } else if ($object->isDir()) {
                    rmdir($object->getPathname());
                }
            }
        }
    }
163884
public static void deleteDirectory(File dir) {
        if (!dir.exists()) {
            return;
        }

        if (dir.isDirectory()) {
            for (File child : dir.listFiles()) {
                deleteDirectory(child);
            }
            dir.delete();
        } else {
            dir.delete();
        }
    }
122508
private function _delete_dir($path = '')
    {
        $cache_path = $this->config->get('cache_path');

        // make sure nobody can delete above the cache root
        if (strpos($path, $cache_path) === false) return;

        if (is_file($path)) {
            return (bool) unlink($path);
        } elseif (is_dir($path)) {
            $scan = glob(rtrim($path,'/').'/*');

            foreach ($scan as $item) {
                $this->_delete_dir($item);
            }

            return rmdir($path);
        }
    }
179590
public static function delete($path)
	{
		if (is_dir($path)) {
			Dir::delete($path);
		} elseif (is_file($path)) {
			File::delete($path);
		}

		return true;
	}
946432
public static function removeFolder($path)
    {
        $path = self::resolve($path);

        return $path && is_dir($path) && self::rrmdir($path);
    }
620099
protected function deleteFile($file, $dir) {
        if ($file != "." && $file != "..") {
            if (is_dir($dir."/".$file)) {
                $this->flushDir($dir."/".$file);
                rmdir($dir."/".$file);
            } else {
                unlink($dir."/".$file);
            }
        }
    }