Delete a file or array of files

@param   mixed  $file  The file name or an array of file names

@return  boolean  True on success

@since   1.0
@throws  FilesystemException
171829
public static function delete($file)
	{
		$files = (array) $file;

		foreach ($files as $file)
		{
			$file     = Path::clean($file);
			$filename = basename($file);

			if (!Path::canChmod($file))
			{
				throw new FilesystemException(__METHOD__ . ': Failed deleting inaccessible file ' . $filename);
			}

			// Try making the file writable first. If it's read-only, it can't be deleted
			// on Windows, even if the parent folder is writable
			@chmod($file, 0777);

			// In case of restricted permissions we zap it one way or the other
			// as long as the owner is either the webserver or the ftp
			if (!@ unlink($file))
			{
				throw new FilesystemException(__METHOD__ . ': Failed deleting ' . $filename);
			}
		}

		return true;
	}
129413
public function deleteFiles(array $files)
    {
        $count = 0;
        try {
            foreach ($files as $file) {
                $this->sevenZip->delEntry($file);
                $count++;
            }
            return $count;
        } catch (Exception $e) {
            throw new Exception('Could not modify archive: '.$e->getMessage(), $e->getCode(), $e);
        }
    }
780231
private static function remove($file = '')
    {
        if (is_dir($file)) {
            self::deleteDirectory($file);
        }
        if (is_file($file)) {
            unlink($file);
        }
    }
780195
public function delete($file)
	{
		$metaFile = $this->getMetaFilePath($file);
		if ($this->fs->exists($metaFile))
			$this->fs->delete($metaFile);
		if ($this->f3->get('CACHE')) {
			$cache = \Cache::instance();
			if ($cache->exists($cacheHash = $this->getCacheHash($file)))
				$cache->clear($cacheHash);
		}
	}
580005
public function deleteFile(FileInterface $file)
    {
        $this->storage->deleteFile($file);
        $this->formatManager->deleteFormats($file);
        $this->em->remove($file);
        $this->em->flush();
    }
371149
public static function delFile($file, $image = false)
    {
        $fileStatic = Folder::getStatic($file);

        if(!file_exists($fileStatic)){
            return;
        }

        if(file_exists($fileStatic) && !is_dir($fileStatic)){
            @unlink($fileStatic);
        }

        if($image){
            $pathInfo = pathinfo($file);

            if($pathInfo['dirname'] == UPLOAD_FOLDER){
                $thumbFolder = THUMB_FOLDER;
            }else{
                $thumbFolder = str_replace(UPLOAD_FOLDER . '/', THUMB_FOLDER . '/', $pathInfo['dirname']);
            }

            $thumbs = glob(Folder::getStatic($thumbFolder . '/' . $pathInfo['filename'] . '_*.' . $pathInfo['extension']));

            if($thumbs){
                foreach($thumbs as $thumb){
                    @unlink($thumb);
                }
            }
        }
    }
600757
public static function Delete( string $file )
   {

      if ( ! \file_exists( $file ) )
      {
         // No deleting required
         return;
      }

      try
      {
         \unlink( $file );
         \clearstatcache();
         if ( ! \file_exists( $file ) )
         {
            // Deleting was successful
            return;
         }
      }
      catch ( \Throwable $ex ) { }

      if ( '\\' === DIRECTORY_SEPARATOR )
      {
         $f = \escapeshellarg( $file );
         try { \exec( "del {$f}" ); }
         catch ( \Throwable $ex )
         {
            throw new IOException( $file, 'Deleting the defined file fails!', \E_USER_ERROR, $ex );
         }
         \clearstatcache();
         if ( \file_exists( $file ) )
         {
            throw new IOException(
               $file,
               'Deleting the defined file fails! No known method works.'
            );
         }
         return;
      }

      try { \exec( "unlink {$file}" ); }
      catch ( \Throwable $ex )
      {
         throw new IOException( $file, 'Deleting the defined file fails!', \E_USER_ERROR, $ex );
      }

      \clearstatcache();

      if ( \file_exists( $file ) )
      {
         throw new IOException(
            $file,
            'Deleting the defined file fails!'
         );
      }

   }
355688
public function remove($files)
    {
        $files = iterator_to_array($this->toIterator($files));
        $files = array_reverse($files);
        foreach ($files as $file) {
            if (!file_exists($file) && !is_link($file)) {
                continue;
            }

            if (is_dir($file) && !is_link($file)) {
                $this->remove(new \FilesystemIterator($file));

                if (true !== @rmdir($file)) {
                    throw new \RuntimeException(sprintf('Failed to remove directory "%s".', $file), 0, null);
                }
            } else {
                // https://bugs.php.net/bug.php?id=52176
                if (defined('PHP_WINDOWS_VERSION_MAJOR') && is_dir($file)) {
                    if (true !== @rmdir($file)) {
                        throw new \RuntimeException(sprintf('Failed to remove file "%s".', $file), 0, null);
                    }
                } else {
                    if (true !== @unlink($file)) {
                        throw new \RuntimeException(sprintf('Failed to remove file "%s".', $file), 0, null);
                    }
                }
            }
        }
    }
1048198
public static function checkFileDeletable($file)
    {
        clearstatcache();
        $dir = dirname($file);
        // Deleting a file requires write permissions on the directory.
        // It does not require write permissions on the file
        return @file_exists($dir) && @is_writable($dir);
    }
311379
private function removeFile(File $file)
	{
		$this->removeFileInFileSystem($file);

		if ($file instanceof Image) {
			$em = $this->getDoctrineEntityManager();
			$imageSizeCn = ImageSize::CN();
			$em->createQuery("DELETE FROM $imageSizeCn s WHERE s.master = :master")
				->setParameter('master', $file->getId())
				->execute();
		}

		$entityManager = $this->getDoctrineEntityManager();
		$entityManager->remove($file);
		$entityManager->flush();
	}
713926
public function delete( $file )
	{
		// check for absolut path
		if ( substr( $file, 0, 1 ) == '/' ) 
		{
			return CCFile::delete( $file );
		}
		
		return CCFile::delete( $this->path( $file ) );
	}
33631
public function prepare($file)
    {
        if (request()->has(static::FILE_DELETE_FLAG)) {
            return $this->destroy();
        }

        $this->name = $this->getStoreName($file);

        return $this->uploadAndDeleteOriginal($file);
    }
671161
public static function clear($file = null)
    {
        if (static::hasEAccelerator()) {
            if (function_exists('eeaccelerator_clear')) {
                $paths = @ini_get('eaccelerator.allowed_admin_path');
                if (is_string($paths) && ($paths !== '')) {
                    $myPath = str_replace(DIRECTORY_SEPARATOR, '/', __DIR__);
                    foreach (explode(PATH_SEPARATOR, $paths) as $path) {
                        $path = str_replace(DIRECTORY_SEPARATOR, '/', $path);
                        if ($path !== '') {
                            $path = rtrim($path, '/');
                            if (($path === $myPath) || (strpos($myPath, $path.'/') === 0)) {
                                @eeaccelerator_clear();
                                break;
                            }
                        }
                    }
                }
            }
        }
        if (static::hasAPC()) {
            if (function_exists('apc_clear_cache')) {
                @apc_clear_cache('system');
            }
        }
        if (static::hasXCache()) {
            if (function_exists('xcache_clear_cache') && ini_get('xcache.admin.user') && ini_get('xcache.admin.pass')) {
                @xcache_clear_cache(XC_TYPE_PHP, 0);
            }
        }
        if (static::hasWinCache()) {
            if (function_exists('wincache_refresh_if_changed')) {
                if ($file) {
                    @wincache_refresh_if_changed((array) $file);
                } else {
                    @wincache_refresh_if_changed();
                }
            }
        }
        if (static::hasZendOpCache()) {
            if ($file && function_exists('opcache_invalidate')) {
                @opcache_invalidate($file, true);
            } elseif (function_exists('opcache_reset')) {
                @opcache_reset();
            }
        }
    }
982225
public static function clear($file = false) {

        if ($file && self::isFile($file)) {

            $f = @fopen($file, "r+");
            if ($f !== false) {
                ftruncate($f, 0);
                fclose($f);

                return true;
            }
        }

        return false;
    }
559719
public static boolean deleteFile(File file) {
        if (file.exists()) {
            if (file.isDirectory()) {
                try {
                    deleteDirectory(file);
                    return true;
                } catch (IOException e) {
                    logger.error(e.getMessage());
                    return false;
                }
            } else {
                return file.delete();
            }
        }
        return false;
    }
1281266
public static function remove($file, $silenceErrors = false)
    {
        if (!file_exists($file)) {
            return;
        }

        $result = @unlink($file);

        // Testing if the file still exist avoids race conditions
        if (!$result && file_exists($file)) {
            if ($silenceErrors) {
                Log::warning('Failed to delete file ' . $file);
            } else {
                throw new \RuntimeException('Unable to delete file ' . $file);
            }
        }
    }
94925
public function deleteAll($file, &$db = 0, &$disk = 0, $check = true)
    {
        if (!is_array($file)) {
            $file = $this->get($file);
        }

        if (!isset($file['file_id'])) {
            return false;
        }

        if (!$this->delete($file['file_id'], $check)) {
            return false;
        }

        $db++;

        if (!$this->deleteFromDisk($file)) {
            return false;
        }

        $disk++;
        return true;
    }