[ Index ]

PHP Cross Reference of Joomla 4.2.2 documentation

title

Body

[close]

/libraries/src/Filesystem/ -> File.php (summary)

Joomla! Content Management System

Copyright: (C) 2006 Open Source Matters, Inc.
License: GNU General Public License version 2 or later; see LICENSE.txt
File Size: 596 lines (20 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

File:: (12 methods):
  getExt()
  stripExt()
  makeSafe()
  copy()
  invalidateFileCache()
  canFlushFileCache()
  delete()
  move()
  write()
  append()
  upload()
  exists()


Class: File  - X-Ref

A File handling class

getExt($file)   X-Ref
Gets the extension of a file name

param: string  $file  The file name
return: string  The file extension

stripExt($file)   X-Ref
Strips the last extension off of a file name

param: string  $file  The file name
return: string  The file name without the extension

makeSafe($file)   X-Ref
Makes file name safe to use

param: string  $file  The name of the file [not full path]
return: string  The sanitised string

copy($src, $dest, $path = null, $useStreams = false)   X-Ref
Copies a file

param: string   $src         The path to the source file
param: string   $dest        The path to the destination file
param: string   $path        An optional base path to prefix to the file names
param: boolean  $useStreams  True to use streams
return: boolean  True on success

invalidateFileCache($filepath, $force = true)   X-Ref
Invalidate opcache for a newly written/deleted file immediately, if opcache* functions exist and if this was a PHP file.

param: string  $filepath   The path to the file just written to, to flush from opcache
param: boolean $force      If set to true, the script will be invalidated regardless of whether invalidation is necessary
return: boolean TRUE if the opcode cache for script was invalidated/nothing to invalidate,

canFlushFileCache()   X-Ref
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, but `realpath()`
is necessary because `SCRIPT_FILENAME` can be a relative path when run from CLI.
If the host has this set, check whether the path in `opcache.restrict_api` matches
the beginning of the path of the origin file.

return: boolean TRUE if we can proceed to use opcache_invalidate to flush a file from the OPCache

delete($file)   X-Ref
Delete a file or array of files

param: mixed  $file  The file name or an array of file names
return: boolean  True on success

move($src, $dest, $path = '', $useStreams = false)   X-Ref
Moves a file

param: string   $src         The path to the source file
param: string   $dest        The path to the destination file
param: string   $path        An optional base path to prefix to the file names
param: boolean  $useStreams  True to use streams
return: boolean  True on success

write($file, $buffer, $useStreams = false)   X-Ref
Write contents to a file

param: string   $file        The full file path
param: string   $buffer      The buffer to write
param: boolean  $useStreams  Use streams
return: boolean  True on success

append($file, $buffer, $useStreams = false)   X-Ref
Append contents to a file

param: string   $file        The full file path
param: string   $buffer      The buffer to write
param: boolean  $useStreams  Use streams
return: boolean  True on success

upload($src, $dest, $useStreams = false, $allowUnsafe = false, $safeFileOptions = array()   X-Ref
Moves an uploaded file to a destination folder

param: string   $src              The name of the php (temporary) uploaded file
param: string   $dest             The path (including filename) to move the uploaded file to
param: boolean  $useStreams       True to use streams
param: boolean  $allowUnsafe      Allow the upload of unsafe files
param: array    $safeFileOptions  Options to InputFilter::isSafeFile
return: boolean  True on success

exists($file)   X-Ref
Wrapper for the standard file_exists function

param: string  $file  File path
return: boolean  True if path is a file



Generated: Wed Sep 7 05:41:13 2022 Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer