JStream/chmod
From Joomla! Documentation
< API16:JStreamRevision as of 17:48, 22 March 2010 by Doxiki (talk | contribs) (New page: ===Description===
chmod wrapper
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>Edit Descripton<nowiki>]</nowiki>
</span>
{{Desc...)
Revision as of 17:48, 22 March 2010 by Doxiki (talk | contribs) (New page: ===Description===
chmod wrapper
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>Edit Descripton<nowiki>]</nowiki>
</span>
{{Desc...)
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[edit]
chmod wrapper
Template:Description:JStream/chmod
Syntax[edit]
chmod($filename='', $mode=0)
Parameter Name | Default Value | Description |
---|---|---|
$filename | Mode to use | |
$mode | 0 |
Defined in[edit]
libraries/joomla/filesystem/stream.php
Importing[edit]
jimport( 'joomla.filesystem.stream' );
Source Body[edit]
function chmod($filename='', $mode=0)
{
if(!$filename)
{
if(!isset($this->filename) || !$this->filename) {
$this->setError(JText::_('Filename not set'));
return false;
}
$filename = $this->filename;
}
// if no mode is set use the default
if(!$mode) $mode = $this->filemode;
$retval = false;
// Capture PHP errors
$php_errormsg = '';
$track_errors = ini_get('track_errors');
ini_set('track_errors', true);
$sch = parse_url($filename, PHP_URL_SCHEME);
// scheme specific options; ftp's chmod support is fun
switch($sch)
{
case 'ftp':
case 'ftps':
$res = JFilesystemHelper::ftpChmod($filename, $mode);
break;
default:
//echo '<p>Chmodding '. $filename . ' with ' . decoct($mode) .'</p>';
$res = chmod($filename, $mode);
break;
}
// seek, interestingly returns 0 on success or -1 on failure
if(!$res) {
$this->setError($php_errormsg);
} else {
$retval = true;
}
// restore error tracking to what it was before
ini_set('track_errors',$track_errors);
// return the result
return $retval;
}
[Edit See Also] Template:SeeAlso:JStream/chmod
Examples[edit]
<CodeExamplesForm />