Liste de tous les membres
Fonctions membres publiques statiques |
static | getExt ($file) |
static | stripExt ($file) |
static | makeSafe ($file) |
static | copy ($src, $dest, $path=null, $use_streams=false) |
static | delete ($file) |
static | move ($src, $dest, $path= '', $use_streams=false) |
static | read ($filename, $incpath=false, $amount=0, $chunksize=8192, $offset=0) |
static | write ($file, &$buffer, $use_streams=false) |
static | upload ($src, $dest, $use_streams=false) |
static | exists ($file) |
static | getName ($file) |
Description détaillée
Définition à la ligne 21 du fichier file.php.
Documentation des fonctions membres
static JFile::copy |
( |
|
$src, |
|
|
|
$dest, |
|
|
|
$path = null , |
|
|
|
$use_streams = false |
|
) |
| |
|
static |
Copies a file
- Paramètres:
-
string | $src | The path to the source file |
string | $dest | The path to the destination file |
string | $path | An optional base path to prefix to the file names |
boolean | $use_streams | True to use streams |
- Renvoie:
- boolean True on success
- Depuis:
- 11.1
Définition à la ligne 84 du fichier file.php.
Références JText\_(), JLog\add(), JPath\clean(), JFolder\create(), JClientHelper\getCredentials(), JClientFtp\getInstance(), JFactory\getStream(), jimport(), JText\sprintf(), et JLog\WARNING.
Référencé par JArchive\extract().
{
if ($path)
{
}
if (!is_readable($src))
{
return false;
}
if ($use_streams)
{
if (!$stream->copy($src, $dest))
{
return false;
}
return true;
}
else
{
if ($FTPOptions['enabled'] == 1)
{
$ftp =
JClientFtp::getInstance($FTPOptions[
'host'], $FTPOptions[
'port'], array(), $FTPOptions[
'user'], $FTPOptions[
'pass']);
if (!file_exists(dirname($dest)))
{
jimport(
'joomla.filesystem.folder');
}
$dest =
JPath::clean(str_replace(JPATH_ROOT, $FTPOptions[
'root'], $dest),
'/');
if (!$ftp->store($src, $dest))
{
return false;
}
$ret = true;
}
else
{
if (!@
copy($src, $dest))
{
return false;
}
$ret = true;
}
return $ret;
}
}
static JFile::delete |
( |
|
$file | ) |
|
|
static |
Delete a file or array of files
- Paramètres:
-
mixed | $file | The file name or an array of file names |
- Renvoie:
- boolean True on success
- Depuis:
- 11.1
Définition à la ligne 165 du fichier file.php.
Références JLog\add(), JPath\clean(), JClientHelper\getCredentials(), JClientFtp\getInstance(), JText\sprintf(), et JLog\WARNING.
Référencé par JFilesystemPatcher\apply(), JFolder\delete(), et JPath\isOwner().
{
if (is_array($file))
{
$files = $file;
}
else
{
$files[] = $file;
}
if ($FTPOptions['enabled'] == 1)
{
$ftp =
JClientFtp::getInstance($FTPOptions[
'host'], $FTPOptions[
'port'], array(), $FTPOptions[
'user'], $FTPOptions[
'pass']);
}
foreach ($files as $file)
{
@chmod($file, 0777);
if (@unlink($file))
{
}
elseif ($FTPOptions['enabled'] == 1)
{
$file =
JPath::clean(str_replace(JPATH_ROOT, $FTPOptions[
'root'], $file),
'/');
if (!$ftp->delete($file))
{
return false;
}
}
else
{
$filename = basename($file);
return false;
}
}
return true;
}
static JFile::exists |
( |
|
$file | ) |
|
|
static |
Wrapper for the standard file_exists function
- Paramètres:
-
- Renvoie:
- boolean True if path is a file
- Depuis:
- 11.1
Définition à la ligne 524 du fichier file.php.
Références JPath\clean().
static JFile::getExt |
( |
|
$file | ) |
|
|
static |
static JFile::getName |
( |
|
$file | ) |
|
|
static |
Returns the name, without any path.
- Paramètres:
-
- Renvoie:
- string filename
- Depuis:
- 11.1
- Obsolète:
- 13.3 (Platform) & 4.0 (CMS) - Use basename() instead.
Définition à la ligne 539 du fichier file.php.
Références JLog\add(), et JLog\WARNING.
Référencé par JGoogleDataPicasaAlbum\upload().
{
$file = str_replace('\\', '/', $file);
$slash = strrpos($file, '/');
if ($slash !== false)
{
return substr($file, $slash + 1);
}
else
{
return $file;
}
}
static JFile::makeSafe |
( |
|
$file | ) |
|
|
static |
Makes file name safe to use
- Paramètres:
-
string | $file | The name of the file [not full path] |
- Renvoie:
- string The sanitised string
- Depuis:
- 11.1
Définition à la ligne 62 du fichier file.php.
{
$file = rtrim($file, '.');
$regex = array('#(\.){2,}#', '#[^A-Za-z0-9\.\_\- ]#', '#^\.#');
return trim(preg_replace($regex, '', $file));
}
static JFile::move |
( |
|
$src, |
|
|
|
$dest, |
|
|
|
$path = '' , |
|
|
|
$use_streams = false |
|
) |
| |
|
static |
Moves a file
- Paramètres:
-
string | $src | The path to the source file |
string | $dest | The path to the destination file |
string | $path | An optional base path to prefix to the file names |
boolean | $use_streams | True to use streams |
- Renvoie:
- boolean True on success
- Depuis:
- 11.1
Définition à la ligne 234 du fichier file.php.
Références JText\_(), JLog\add(), JPath\clean(), JClientHelper\getCredentials(), JClientFtp\getInstance(), JFactory\getStream(), JText\sprintf(), et JLog\WARNING.
{
if ($path)
{
}
if (!is_readable($src))
{
return JText::_(
'JLIB_FILESYSTEM_CANNOT_FIND_SOURCE_FILE');
}
if ($use_streams)
{
if (!$stream->move($src, $dest))
{
return false;
}
return true;
}
else
{
if ($FTPOptions['enabled'] == 1)
{
$ftp =
JClientFtp::getInstance($FTPOptions[
'host'], $FTPOptions[
'port'], array(), $FTPOptions[
'user'], $FTPOptions[
'pass']);
$src =
JPath::clean(str_replace(JPATH_ROOT, $FTPOptions[
'root'], $src),
'/');
$dest =
JPath::clean(str_replace(JPATH_ROOT, $FTPOptions[
'root'], $dest),
'/');
if (!$ftp->rename($src, $dest))
{
return false;
}
}
else
{
if (!@ rename($src, $dest))
{
return false;
}
}
return true;
}
}
static JFile::read |
( |
|
$filename, |
|
|
|
$incpath = false , |
|
|
|
$amount = 0 , |
|
|
|
$chunksize = 8192 , |
|
|
|
$offset = 0 |
|
) |
| |
|
static |
Read the contents of a file
- Paramètres:
-
string | $filename | The full file path |
boolean | $incpath | Use include path |
integer | $amount | Amount of file to read |
integer | $chunksize | Size of chunks to read |
integer | $offset | Offset of the file |
- Renvoie:
- mixed Returns file contents or boolean False if failed
- Depuis:
- 11.1
- Obsolète:
- 13.3 (Platform) & 4.0 (CMS) - Use the native file_get_contents() instead.
Définition à la ligne 311 du fichier file.php.
Références JLog\add(), JText\sprintf(), et JLog\WARNING.
Référencé par JGoogleDataPicasaAlbum\upload().
{
JLog::add(__METHOD__ .
' is deprecated. Use native file_get_contents() syntax.',
JLog::WARNING,
'deprecated');
$data = null;
if ($amount && $chunksize > $amount)
{
$chunksize = $amount;
}
if (false === $fh = fopen($filename, 'rb', $incpath))
{
return false;
}
clearstatcache();
if ($offset)
{
fseek($fh, $offset);
}
if ($fsize = @ filesize($filename))
{
if ($amount && $fsize > $amount)
{
$data = fread($fh, $amount);
}
else
{
$data = fread($fh, $fsize);
}
}
else
{
$data = '';
while (!feof($fh) && (!$amount || strlen($data) < $amount))
{
$data .= fread($fh, $chunksize);
}
}
fclose($fh);
return $data;
}
static JFile::stripExt |
( |
|
$file | ) |
|
|
static |
static JFile::upload |
( |
|
$src, |
|
|
|
$dest, |
|
|
|
$use_streams = false |
|
) |
| |
|
static |
Moves an uploaded file to a destination folder
- Paramètres:
-
string | $src | The name of the php (temporary) uploaded file |
string | $dest | The path (including filename) to move the uploaded file to |
boolean | $use_streams | True to use streams |
- Renvoie:
- boolean True on success
- Depuis:
- 11.1
Définition à la ligne 440 du fichier file.php.
Références JText\_(), JLog\add(), JPath\clean(), JFolder\create(), JClientHelper\getCredentials(), JClientFtp\getInstance(), JFactory\getStream(), jimport(), JPath\setPermissions(), JText\sprintf(), et JLog\WARNING.
{
$baseDir = dirname($dest);
if (!file_exists($baseDir))
{
jimport(
'joomla.filesystem.folder');
}
if ($use_streams)
{
if (!$stream->upload($src, $dest))
{
return false;
}
return true;
}
else
{
$ret = false;
if ($FTPOptions['enabled'] == 1)
{
$ftp =
JClientFtp::getInstance($FTPOptions[
'host'], $FTPOptions[
'port'], array(), $FTPOptions[
'user'], $FTPOptions[
'pass']);
$dest =
JPath::clean(str_replace(JPATH_ROOT, $FTPOptions[
'root'], $dest),
'/');
if (is_uploaded_file($src) && $ftp->store($src, $dest))
{
unlink($src);
$ret = true;
}
else
{
}
}
else
{
if (is_writeable($baseDir) && move_uploaded_file($src, $dest))
{
{
$ret = true;
}
else
{
}
}
else
{
}
}
return $ret;
}
}
static JFile::write |
( |
|
$file, |
|
|
& |
$buffer, |
|
|
|
$use_streams = false |
|
) |
| |
|
static |
Write contents to a file
- Paramètres:
-
string | $file | The full file path |
string | &$buffer | The buffer to write |
boolean | $use_streams | Use streams |
- Renvoie:
- boolean True on success
- Depuis:
- 11.1
Définition à la ligne 379 du fichier file.php.
Références JLog\add(), JPath\clean(), JFolder\create(), JClientHelper\getCredentials(), JClientFtp\getInstance(), JFactory\getStream(), jimport(), JText\sprintf(), et JLog\WARNING.
Référencé par JArchiveZip\_createZIPFile(), JFilesystemPatcher\apply(), JArchiveBzip2\extract(), JArchiveGzip\extract(), JArchiveTar\extract(), JArchiveZip\extractCustom(), JArchiveZip\extractNative(), et JPath\isOwner().
{
@set_time_limit(ini_get('max_execution_time'));
if (!file_exists(dirname($file)))
{
jimport(
'joomla.filesystem.folder');
}
if ($use_streams)
{
$stream->set('chunksize', (1024 * 1024));
if (!$stream->writeFile($file, $buffer))
{
return false;
}
return true;
}
else
{
if ($FTPOptions['enabled'] == 1)
{
$ftp =
JClientFtp::getInstance($FTPOptions[
'host'], $FTPOptions[
'port'], array(), $FTPOptions[
'user'], $FTPOptions[
'pass']);
$file =
JPath::clean(str_replace(JPATH_ROOT, $FTPOptions[
'root'], $file),
'/');
$ret = $ftp->write($file, $buffer);
}
else
{
$ret = is_int(file_put_contents($file, $buffer)) ? true : false;
}
return $ret;
}
}
La documentation de cette classe a été générée à partir du fichier suivant :
- jplatform-13.1/joomla/filesystem/file.php