API16

JStream/delete

< API16:JStream

The "API16" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.

Description

Delete a file



Syntax

delete($filename, $context=null, $use_prefix=true, $relative=false)
Parameter Name Default Value Description
$filename
$context null
$use_prefix true
$relative false

Defined in

libraries/joomla/filesystem/stream.php

Importing

jimport( 'joomla.filesystem.stream' );

Source Body

function delete($filename, $context=null, $use_prefix=true, $relative=false)
{
        $res = false;
        // Capture PHP errors
        $php_errormsg = '';
        $track_errors = ini_get('track_errors');
        ini_set('track_errors', true);

        $filename = $this->_getFilename($filename, 'w', $use_prefix, $relative);
        if($context) { // use the provided context
                $res = @unlink($filename, $context);
        } else if($this->_context) { // use the objects context
                $res = @unlink($filename, $this->_context);
        } else { // don't use any context
                $res = @unlink($filename);
        }
        if(!$res && $php_errormsg) {
                $this->setError($php_errormsg());
        }

        // restore error tracking to what it was before
        ini_set('track_errors',$track_errors);
        return $res;
}



Examples

Code Examples


Advertisement