Back to Joomla project (class list)

Class File - list of methods

A File handling class
Package: Joomla\CMS\Filesystem
Copyright: (C) 2006 Open Source Matters, Inc.
License: GNU General Public License version 2 or later; see LICENSE.txt
Located at: Joomla/Filesystem/File.php
Project: Joomla

Method Summary

public static string
(mixed $file)

Gets the extension of a file name
Parameters
  • string $file The file name
Returns
  • string The file extension
Since
  • 1.7.0
Show source code of this method: getExt Source Code

public static string
(mixed $file)

Strips the last extension off of a file name
Parameters
  • string $file The file name
Returns
  • string The file name without the extension
Since
  • 1.7.0
Show source code of this method: stripExt Source Code

public static string
(mixed $file)

Makes file name safe to use
Parameters
  • string $file The name of the file [not full path]
Returns
  • string The sanitised string
Since
  • 1.7.0
Show source code of this method: makeSafe Source Code

public static bool
(mixed $src, mixed $dest, mixed $path = null, mixed $useStreams = false)

Copies a file
Parameters
  • 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
  • bool $useStreams True to use streams
Returns
  • bool True on success
Since
  • 1.7.0
Show source code of this method: copy Source Code

public static bool
(mixed $filepath, mixed $force = true)

Invalidate opcache for a newly written/deleted file immediately, if opcache* functions exist and if this was a PHP file.
Parameters
  • string $filepath The path to the file just written to, to flush from opcache
  • bool $force If set to true, the script will be invalidated regardless of whether invalidation is necessary
Returns
  • bool 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).
Since
  • 4.0.1
Show source code of this method: invalidateFileCache Source Code

public static bool
()

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.
Returns
  • bool TRUE if we can proceed to use opcache_invalidate to flush a file from the OPCache
Since
  • 4.0.1
Show source code of this method: canFlushFileCache Source Code

public static bool
(mixed $file)

Delete a file or array of files
Parameters
  • mixed $file The file name or an array of file names
Returns
  • bool True on success
Since
  • 1.7.0
Show source code of this method: delete Source Code

public static bool
(mixed $src, mixed $dest, mixed $path = '', mixed $useStreams = false)

Moves a file
Parameters
  • 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
  • bool $useStreams True to use streams
Returns
  • bool True on success
Since
  • 1.7.0
Show source code of this method: move Source Code

public static bool
(mixed $file, mixed $buffer, mixed $useStreams = false)

Write contents to a file
Parameters
  • string $file The full file path
  • string $buffer The buffer to write
  • bool $useStreams Use streams
Returns
  • bool True on success
Since
  • 1.7.0
Show source code of this method: write Source Code

public static bool
(mixed $file, mixed $buffer, mixed $useStreams = false)

Append contents to a file
Parameters
  • string $file The full file path
  • string $buffer The buffer to write
  • bool $useStreams Use streams
Returns
  • bool True on success
Since
  • 3.6.0
Show source code of this method: append Source Code

public static bool
(mixed $src, mixed $dest, mixed $useStreams = false, mixed $allowUnsafe = false, mixed $safeFileOptions = array())

Moves an uploaded file to a destination folder
Parameters
  • string $src The name of the php (temporary) uploaded file
  • string $dest The path (including filename) to move the uploaded file to
  • bool $useStreams True to use streams
  • bool $allowUnsafe Allow the upload of unsafe files
  • array $safeFileOptions Options to InputFilter::isSafeFile
Returns
  • bool True on success
Since
  • 1.7.0
Show source code of this method: upload Source Code

public static bool
(mixed $file)

Wrapper for the standard file_exists function
Parameters
  • string $file File path
Returns
  • bool True if path is a file
Since
  • 1.7.0
Show source code of this method: exists Source Code

Properties Summary

protected static bool
$canFlushFileCache
Since
  • 4.0.1

Tags Summary

Since
1.7.0