Joomla CMS  4.2.2
Documentation des API du CMS Joomla en version 4.2.2
Référence de la classe File

Fonctions membres publiques statiques

static getExt ($file)
 
static stripExt ($file)
 
static makeSafe ($file)
 
static copy ($src, $dest, $path=null, $useStreams=false)
 
static invalidateFileCache ($filepath, $force=true)
 
static canFlushFileCache ()
 
static delete ($file)
 
static move ($src, $dest, $path='', $useStreams=false)
 
static write ($file, $buffer, $useStreams=false)
 
static append ($file, $buffer, $useStreams=false)
 
static upload ($src, $dest, $useStreams=false, $allowUnsafe=false, $safeFileOptions=array())
 
static exists ($file)
 

Attributs protégés statiques

static $canFlushFileCache
 

Description détaillée

A File handling class

Depuis
1.7.0

Documentation des fonctions membres

◆ append()

static append (   $file,
  $buffer,
  $useStreams = false 
)
static

Append contents to a file

Paramètres
string$fileThe full file path
string$bufferThe buffer to write
boolean$useStreamsUse streams
Renvoie
boolean True on success
Depuis
3.6.0

Références $buffer, Laminas\Diactoros\$stream, Log\add(), Path\clean(), ClientHelper\getCredentials(), FtpClient\getInstance(), Factory\getStream(), JPATH_ROOT, Text\sprintf(), et Log\WARNING.

◆ canFlushFileCache()

static canFlushFileCache ( )
static

First we check if opcache is enabled Then we check if the opcache_invalidate function is available Lastly we check if the host has restricted which scripts can use opcache_invalidate using opcache.restrict_api.

‘$_SERVER['SCRIPT_FILENAME’]approximates the origin file's path, butrealpath() is necessary becauseSCRIPT_FILENAMEcan be a relative path when run from CLI. If the host has this set, check whether the path inopcache.restrict_api` matches the beginning of the path of the origin file.

Renvoie
boolean TRUE if we can proceed to use opcache_invalidate to flush a file from the OPCache
Depuis
4.0.1

◆ copy()

static copy (   $src,
  $dest,
  $path = null,
  $useStreams = false 
)
static

Copies a file

Paramètres
string$srcThe path to the source file
string$destThe path to the destination file
string$pathAn optional base path to prefix to the file names
boolean$useStreamsTrue to use streams
Renvoie
boolean True on success
Depuis
1.7.0

Références $path, Laminas\Diactoros\$stream, Log\add(), Path\clean(), Folder\create(), ClientHelper\getCredentials(), FtpClient\getInstance(), Factory\getStream(), JPATH_ROOT, Text\sprintf(), et Log\WARNING.

Référencé par TemplateModel\child(), TemplateModel\copy(), LocalAdapter\copyFile(), TemplateModel\copyFile(), Installer\copyFiles(), et TemplateModel\createTemplateOverride().

◆ delete()

static delete (   $file)
static

Delete a file or array of files

Paramètres
mixed$fileThe file name or an array of file names
Renvoie
boolean True on success
Depuis
1.7.0

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

Invalidate the OPCache for the file before actually deleting it

Voir également
https://github.com/joomla/joomla-cms/pull/32915#issuecomment-812865635
https://www.php.net/manual/en/function.opcache-invalidate.php#116372

In case of restricted permissions we delete it one way or the other as long as the owner is either the webserver or the ftp

Références Log\add(), Path\clean(), elseif, ClientHelper\getCredentials(), FtpClient\getInstance(), JPATH_ROOT, Text\sprintf(), et Log\WARNING.

Référencé par Installer\abort(), Patcher\apply(), LocalAdapter\checkContent(), UpdateModel\cleanUp(), InstallerHelper\cleanupInstall(), LocalAdapter\copyFolder(), UpdateModel\createUpdateFile(), LocalAdapter\delete(), Folder\delete(), ConfigurationModel\deleteConfiguration(), TemplateModel\deleteFile(), CleanupModel\deleteInstallationFolder(), UpdateModel\downloadPackage(), FileAdapter\finaliseUninstall(), PackageAdapter\finaliseUninstall(), TracksModel\getContent(), OverridesModel\getOverrides(), Path\isOwner(), LocalAdapter\moveFolder(), Installer\parseFiles(), FileAdapter\removeExtensionFiles(), LibraryAdapter\removeExtensionFiles(), InstallerScript\removeFiles(), Installer\removeFiles(), UpdateModel\removePackageFiles(), et UpdateCoreCommand\updateJoomlaCore().

◆ exists()

◆ getExt()

◆ invalidateFileCache()

static invalidateFileCache (   $filepath,
  $force = true 
)
static

Invalidate opcache for a newly written/deleted file immediately, if opcache* functions exist and if this was a PHP file.

Paramètres
string$filepathThe path to the file just written to, to flush from opcache
boolean$forceIf set to true, the script will be invalidated regardless of whether invalidation is necessary
Renvoie
boolean TRUE if the opcode cache for script was invalidated/nothing to invalidate, or FALSE if the opcode cache is disabled or other conditions returning FALSE from opcache_invalidate (like file not found).
Depuis
4.0.1

Référencé par FileStorage\__construct(), FileStorage\_checkExpire(), FileStorage\_deleteFolder(), UpdateModel\createUpdateFile(), FileStorage\gc(), et FileStorage\remove().

◆ makeSafe()

static makeSafe (   $file)
static

Makes file name safe to use

Paramètres
string$fileThe name of the file [not full path]
Renvoie
string The sanitised string
Depuis
1.7.0

Référencé par TemplateHelper\canUpload(), MediaHelper\canUpload(), ContenthistoryHelper\getFormFile(), LocalAdapter\getSafeName(), et TemplateModel\uploadFile().

◆ move()

static move (   $src,
  $dest,
  $path = '',
  $useStreams = false 
)
static

Moves a file

Paramètres
string$srcThe path to the source file
string$destThe path to the destination file
string$pathAn optional base path to prefix to the file names
boolean$useStreamsTrue to use streams
Renvoie
boolean True on success
Depuis
1.7.0

Références $path, Laminas\Diactoros\$stream, Text\_(), Log\add(), Path\clean(), ClientHelper\getCredentials(), FtpClient\getInstance(), Factory\getStream(), JPATH_ROOT, Text\sprintf(), et Log\WARNING.

Référencé par CleanupModel\deleteInstallationFolder(), TemplateModel\fixTemplateName(), InstallerScript\moveCliFiles(), et LocalAdapter\moveFile().

◆ stripExt()

◆ upload()

static upload (   $src,
  $dest,
  $useStreams = false,
  $allowUnsafe = false,
  $safeFileOptions = array() 
)
static

Moves an uploaded file to a destination folder

Paramètres
string$srcThe name of the php (temporary) uploaded file
string$destThe path (including filename) to move the uploaded file to
boolean$useStreamsTrue to use streams
boolean$allowUnsafeAllow the upload of unsafe files
array$safeFileOptionsOptions to InputFilter::isSafeFile
Renvoie
boolean True on success
Depuis
1.7.0

Références $baseDir, Laminas\Diactoros\$stream, Text\_(), Log\add(), Path\clean(), Folder\create(), ClientHelper\getCredentials(), FtpClient\getInstance(), Factory\getStream(), InputFilter\isSafeFile(), JPATH_ROOT, Path\setPermissions(), Text\sprintf(), et Log\WARNING.

Référencé par InstallModel\_getPackageFromUpload(), UpdateModel\upload(), et TemplateModel\uploadFile().

◆ write()

Documentation des champs

◆ $canFlushFileCache

$canFlushFileCache
staticprotected

La documentation de cette classe a été générée à partir du fichier suivant :