Wrapper function useful for deleting an existing file (if present) just
before creating a new one.

@param file_storage $fs File storage
@param array $filerecord File record in same format used to create file
332729
public static function delete_existing_file_record(file_storage $fs, array $filerecord) {
        if ($existing = $fs->get_file($filerecord['contextid'], $filerecord['component'],
                $filerecord['filearea'], $filerecord['itemid'], $filerecord['filepath'],
                $filerecord['filename'])) {
            $existing->delete();
        }
    }
1327736
public function process(EventRecord $eventRecord): void
    {
        $this->eventStore->append($eventRecord);
        $this->eventDispatcher->dispatch($eventRecord->eventMessage());
    }
993576
public function create_children(&$records, &$children, $thisrecordid) {
        //keys where value is $thisrecordid
        $thischildren = array_keys($children, $thisrecordid);
        foreach ($thischildren as $child) {
            $thisclass = get_class($this);
            $newlistitem = new $thisclass($records[$child], $this->children, $this->attributes);
            $this->children->add_item($newlistitem);
            $newlistitem->create_children($records, $children, $records[$child]->id);
        }
    }
1216556
def record_to_fs(self):
        """"""

        fr = self.record

        if fr.contents:
            with self._fs.open(self.file_name, 'w', encoding='utf-8') as f:
                self.record_to_fh(f)
765480
public static function deleteImage($fileName, $context, $storage = 'local')
    {
        /** @var Processor $processor */
        $processor = app('icr.processor');

        return $processor->delete($fileName, $context, Facades\Storage::disk($storage));
    }
817785
public void setFilesDeleted(java.util.Collection<FileMetadata> filesDeleted) {
        if (filesDeleted == null) {
            this.filesDeleted = null;
            return;
        }

        this.filesDeleted = new java.util.ArrayList<FileMetadata>(filesDeleted);
    }
306702
private function deleteFile($file) {
		try {
			if($this->client && $this->client->enabled()) {
				$this->client->delete($file);
			}
		}
		catch(StorageException $ex) {
			Logger::error("Error deleting file '$file'.", ['exception' => $ex->getMessage(), 'Key' => $file]);
		}
	}
1265677
protected function createDataObject($fileID)
    {
        $recordClass = $this->component->getRecordClassName($this->gridField);
        $record = $recordClass::create();
        $record->write();

        $record->extend('onBulkUpload', $this->gridField);

        $fileRelationName = $this->component->getFileRelationName($this->gridField);
        $record->{"{$fileRelationName}ID"} = $fileID;
        $record->write(); //HasManyList call write on record but not ManyManyList, so we call it here again
        
        $this->gridField->list->add($record);

        if ($this->component->getAutoPublishDataObject() && $record->hasExtension('Versioned'))
        {
            $record->publishRecursive();
        }

        return $record;
    }
889416
protected function deleteFile($fileName)
    {
        if (null !== $fileName && $this->mediaStorageManager->exists($fileName)) {
            $this->mediaStorageManager->deleteContent($fileName);
        }
    }
1173495
public function addFileset(FileSet $fs)
    {
        if ($this->isReference()) {
            throw $this->noChildrenAllowed();
        }
        $this->elements[] = $fs;
        $this->checked = false;
    }
997637
public function delete($fileIDs)
    {
        if (is_array($fileIDs)) {
            $fileIDs = implode(',', $fileIDs);
        }

        $data = [
            'file_ids' => $fileIDs
        ];

        return $this->post('files/delete', $data, \true);
    }
966880
function delete_file($filepath)
	{
		if ( ! $this->_is_conn())
		{
			return false;
		}

		$result = @ftp_delete($this->_conn_id, $filepath);

		if ($result === false)
		{
			if ($this->_debug == true)
			{
				throw new \FtpFileAccessException('Unable to delete');
			}
			return false;
		}

		return true;
	}
1125235
public function delete($file_id){
        $filename=$this->config['base_path'].DIRECTORY_SEPARATOR.$file_id;
        unlink(ROOT_PATH.$filename);
        $p=explode(DIRECTORY_SEPARATOR,$file_id);
        $name=array_pop($p);
        $name_ext=explode(".",$name);
        $save_name=ROOT_PATH.$this->config['base_path'].DIRECTORY_SEPARATOR.implode(DIRECTORY_SEPARATOR,$p).DIRECTORY_SEPARATOR
            .$name_ext[0].DIRECTORY_SEPARATOR;
        $files = (array) glob($save_name . '*');
        var_dump($save_name);
        foreach ($files as $path) {
            if (is_dir($path)) {
                array_map('unlink', glob($path . '/*.php'));
            } else {
                unlink($path);
            }
        }
        rmdir($save_name);
    }
679566
function mock_fsmerge( & $fs, & $comp) {
		if (isset($comp['%type']) && $comp['%type'] == 'file') {
			throw new \Exception('[Mock] Tried to copy file as directory.');
		}

		// map existing files
		$existing_files = [];
		foreach ($fs as $node => $file) {
			if (is_integer($node)) {
				$existing_files[] = $file['filename'];
			}
		}

		// merge
		foreach ($comp as $node => $file) {
			if (is_integer($node)) {
				if (in_array($file['filename'], $existing_files)) {
					throw new \Exception("[Mock] Tried to overwrite file: {$file['filename']}");
				}
				$fs[] = $file;
			}
			else if ($node[0] == '%') { // attribute
				$fs[$node] = $file;
			}
			else { // dir
				isset($fs[$node]) or $fs[$node] = [];
				$this->mock_fsmerge($fs[$node], $file);
			}
		}
	}
876041
static function instance(\hlin\archetype\Filesystem $fs, array $filemaps) {
		$i = new static;
		$i->fs = $fs;
		$i->filemaps = $filemaps;
		return $i;
	}
848974
public function delete($file_name)
	{
		if (!\Entrust::can('delete-backups')) {
	        abort(403, 'Unauthorized access - you do not have the necessary permission to delete backups.');
	    }

		$disk = Storage::disk(config('dick.backupmanager.disk'));

		if ($disk->exists('backups/'.$file_name)) {
			$disk->delete('backups/'.$file_name);

			return 'success';
		}
		else
		{
			abort(404, "The backup file doesn't exist.");
		}
	}
1223363
function FileMaker_Command_Delete($fm, $layout, $recordId)
    {
        $this->_impl = new FileMaker_Command_Delete_Implementation($fm, $layout, $recordId);
    }