File
A File handling class
since |
1.7.0 |
---|---|
package |
Joomla CMS |
Methods
append
Append contents to a file
append(string file, string buffer, bool useStreams = false) : bool
since |
3.6.0 |
---|
Arguments
- file
string
The full file path- buffer
string
The buffer to write- useStreams
bool
Use streams
Response
bool
True on success
canFlushFileCache
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.
canFlushFileCache() : bool
$_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.
since |
4.0.1 |
---|
Response
bool
TRUE if we can proceed to use opcache_invalidate to flush a file from the OPCache
copy
Copies a file
copy(string src, string dest, string path = null, bool useStreams = false) : bool
since |
1.7.0 |
---|
Arguments
- src
string
The path to the source file- dest
string
The path to the destination file- path
string
An optional base path to prefix to the file names- useStreams
bool
True to use streams
Response
bool
True on success
delete
Delete a file or array of files
delete(mixed file) : bool
since |
1.7.0 |
---|
Arguments
- file
mixed
The file name or an array of file names
Response
bool
True on success
exists
Wrapper for the standard file_exists function
exists(string file) : bool
since |
1.7.0 |
---|
Arguments
- file
string
File path
Response
bool
True if path is a file
getExt
Gets the extension of a file name
getExt(string file) : string
since |
1.7.0 |
---|
Arguments
- file
string
The file name
Response
string
The file extension
invalidateFileCache
Invalidate opcache for a newly written/deleted file immediately, if opcache* functions exist and if this was a PHP file.
invalidateFileCache(string filepath, bool force = true) : bool
since |
4.0.1 |
---|
Arguments
- filepath
string
The path to the file just written to, to flush from opcache- force
bool
If set to true, the script will be invalidated regardless of whether invalidation is necessary
Response
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).
makeSafe
Makes file name safe to use
makeSafe(string file) : string
since |
1.7.0 |
---|
Arguments
- file
string
The name of the file [not full path]
Response
string
The sanitised string
move
Moves a file
move(string src, string dest, string path = '', bool useStreams = false) : bool
since |
1.7.0 |
---|
Arguments
- src
string
The path to the source file- dest
string
The path to the destination file- path
string
An optional base path to prefix to the file names- useStreams
bool
True to use streams
Response
bool
True on success
stripExt
Strips the last extension off of a file name
stripExt(string file) : string
since |
1.7.0 |
---|
Arguments
- file
string
The file name
Response
string
The file name without the extension
upload
Moves an uploaded file to a destination folder
upload(string src, string dest, bool useStreams = false, bool allowUnsafe = false, array safeFileOptions = array()) : bool
since |
1.7.0 |
---|
Arguments
- src
string
The name of the php (temporary) uploaded file- dest
string
The path (including filename) to move the uploaded file to- useStreams
bool
True to use streams- allowUnsafe
bool
Allow the upload of unsafe files- safeFileOptions
array
Options to InputFilter::isSafeFile
Response
bool
True on success
write
Write contents to a file
write(string file, string buffer, bool useStreams = false) : bool
since |
1.7.0 |
---|
Arguments
- file
string
The full file path- buffer
string
The buffer to write- useStreams
bool
Use streams
Response
bool
True on success
Properties
canFlushFileCache
true if OPCache enabled, and we have permission to invalidate files