Delete a given file.

Override default implementation. Mark as deleted and remove files from file system.

Keep file in order to provide all file references.

@return boolean
492957
public function delete()
    {
        if ($this->beforeDelete()) {
            if (!Yii::$app->storage->fileSystemDeleteFile($this->name_new_compound)) {
                Logger::error("Unable to remove file from filesystem: " . $this->name_new_compound);
            }
            
            $this->updateAttributes(['is_deleted' => true]);
            
            $this->afterDelete();
            return true;
        }
    }
1274475
public function delete()
	{
		$asset = Model::oneByName($this->getAssetName());

		if ($asset->get('id'))
		{
			if (!$asset->destroy())
			{
				return false;
			}
		}

		return true;
	}
1181078
public function destroy()
	{
		$path = $this->path();

		if (file_exists($path))
		{
			if (!\Filesystem::delete($path))
			{
				$this->addError('Unable to delete file.');

				return false;
			}
		}

		return parent::destroy();
	}
377320
public function deleteAll()
    {
        if ($this->isAbsolute()) {
            if ($this->isFile() || $this->isLink()) {
                // delete file and symlink
                return unlink($this->getPathname());
            } elseif ($this->isDir()) {
                // delete directories and its content
                return $this->deleteAction($this->getPathname(), true);
            }
            return false;
        } else {
            throw new FileException('Given file path is not a absolute path.');
        }
    }
377362
public function delete()
    {
        $rawContent = $this->getRawContent();
        $filePath   = $this->attributes['file_path'];
        $logContent = file_get_contents($filePath);
        $logContent = str_replace($rawContent, '', $logContent);

        file_put_contents($filePath, $logContent);

        return true;
    }
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));
		}
	}
801705
public function delete()
    {
        if (self::$generic_file->canRemoveFiles()) {
            $file_usage_count = 0;

            if (method_exists($this, 'getFileUsageCount')) {
                $file_usage_count = $this->getFileUsageCount($this);
            }

            if ($file_usage_count <= 1) {
                self::$generic_file->delete($this);
            }
        }

        return parent::delete();
    }
889901
public function delete()
    {
        $report = array();
        $options = func_get_args();
        $options = array_combine(
            array_filter($options, function ($v) {return (bool) $v&2;}),
            array_filter($options, function ($v) {return (bool) ($v-1)&2;})
        );

        // exact matching
        if (isset($options[PCLZIP_OPT_BY_NAME]))
            $selectFilter = function ($key, $value) use ($options) {
                $allowedNames = is_array($options[PCLZIP_OPT_BY_NAME])
                    ? $options[PCLZIP_OPT_BY_NAME]
                    : explode(',', $options[PCLZIP_OPT_BY_NAME]);
                foreach ($allowedNames as $name) {
                    // select directory with nested files
                    if (in_array(substr($name, -1), array('/', '\\'))) {
                        if (strncasecmp($name, $key, strlen($name)) === 0) {
                            // that's a file inside a dir or that dir
                            return self::SELECT_FILTER_PASS;
                        }
                    } else {
                        // select exact name only
                        if (strcasecmp($name, $key) === 0) {
                            // that's a file with this name
                            return self::SELECT_FILTER_PASS;
                        }
                    }
                }

                // that file is not in allowed list
                return self::SELECT_FILTER_REFUSE;
            };
        // <ereg> rule
        else if (isset($options[PCLZIP_OPT_BY_EREG]) && function_exists('ereg'))
            $selectFilter = function ($key, $value) use ($options) {
                return (ereg($options[PCLZIP_OPT_BY_EREG], $key) !== false)
                    ? self::SELECT_FILTER_PASS
                    : self::SELECT_FILTER_REFUSE;
            };
        // <preg_match> rule
        else if (isset($options[PCLZIP_OPT_BY_PREG]))
            $selectFilter = function ($key, $value) use ($options) {
                return preg_match($options[PCLZIP_OPT_BY_PREG], $key)
                    ? self::SELECT_FILTER_PASS
                    : self::SELECT_FILTER_REFUSE;
            };
        // index rule
        else if (isset($options[PCLZIP_OPT_BY_INDEX]))
            $selectFilter = function ($key, $value, $index) use ($options) {
                $allowedIndexes = array();
                foreach ($options[PCLZIP_OPT_BY_INDEX] as $rule) {
                    $parts = explode('-', $rule);
                    if (count($parts) == 1) $allowedIndexes[] = $rule;
                    else $allowedIndexes = array_merge(
                        range($parts[0], $parts[1]), $allowedIndexes);
                }

                return in_array($index, $allowedIndexes)
                    ? self::SELECT_FILTER_PASS
                    : self::SELECT_FILTER_REFUSE;
            };
        // no rule
        else
            $selectFilter = function () { return self::SELECT_FILTER_PASS; };

        foreach ($this->listContent() as $file_header) {
            // select by select rule
            if (call_user_func($selectFilter, $file_header->stored_filename,
                    $file_header->filename, $file_header->index)
                === self::SELECT_FILTER_REFUSE) {
                // delete file from archive
                if ($this->archive->deleteName($file_header->stored_filename)) {
                    // ok
                    continue;
                }
                // deletion fails
                else {
                    return 0;
                }
            }
            // unselected file add in report
            $report[] = $file_header;
        }

        return $report;
    }
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;
    }
242835
public function prune() {
		if ( ! $this->enabled ) {
			return false;
		}

		/** @var Finder $finder */
		$finder = $this->get_finder()->sortByName();

		$files_to_delete = array();

		foreach ( $finder as $file ) {
			$pieces    = explode( '-', $file->getBasename( $file->getExtension() ) );
			$timestamp = end( $pieces );

			// No way to compare versions, do nothing.
			if ( ! is_numeric( $timestamp ) ) {
				continue;
			}

			$basename_without_timestamp = str_replace( '-' . $timestamp, '', $file->getBasename() );

			// There's a file with an older timestamp, delete it.
			if ( isset( $files_to_delete[ $basename_without_timestamp ] ) ) {
				unlink( $files_to_delete[ $basename_without_timestamp ] );
			}

			$files_to_delete[ $basename_without_timestamp ] = $file->getRealPath();
		}

		return true;
	}
1253262
protected function deleteFile()
    {
        $this->controlAccess('file_delete');

        if ($this->file->deleteAll($this->data_file['file_id'])) {
            $this->redirect('admin/content/file', $this->text('File has been deleted from database and disk'), 'success');
        }

        // Redirect in any case as file can be already deleted from the database
        $this->redirect('admin/content/file', $this->text('An error occurred'), 'warning');
    }
766071
public function delete() : bool
    {
        $removed = null;

        if ($this->isDirectory()) {
            $removed = rmdir($this->realPath);
        } else {
            $removed = unlink($this->realPath);
        }

        return $removed;
    }
1305714
public function clear()
    {
        foreach ($this->filesystem()->listContents() as $file) {
            $this->filesystem()->delete($file['path']);
        }

        return true;
    }
604021
public function delete($file)
    {
        return ($this->isConnected() === true) ? ftp_delete($this->getConnection(), $file) : false;
    }
1131866
public function delete() {
		
		$log_file = glob ( $this->path . '/'.$this->fileName );

		if (! empty ( $log_file ) && File::exists ( $log_file[0] ) ) {
			return File::delete ( $log_file [0] );
		}
	}
1238215
public static function delete($file)
	{
		$files = (array) $file;

		foreach ($files as $file) {
			$file = FileHelper::cleanPath($file);

			// 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 Exception(__METHOD__ . ': Failed deleting ' . basename($file));
			}
		}

		return true;
	}
51256
public function delete()
    {
        if ($this->files->exists($path = $this->manifestPath.'/collections.json'))
        {
            return $this->files->delete($path);
        }
        else
        {
            return false;
        }
    }