File

A File handling class

since

1.0

package

Joomla Framework

Methods

copy

Copies a file

copy(string src, string dest, string path = null, bool useStreams = false) : bool
static
since

1.0

throws

\Joomla\Filesystem\Exception\FilesystemException

\UnexpectedValueException

Arguments

src

stringThe path to the source file

dest

stringThe path to the destination file

path

stringAn optional base path to prefix to the file names

useStreams

boolTrue to use streams

Response

boolTrue on success

delete

Delete a file or array of files

delete(mixed file) : bool
static
since

1.0

throws

\Joomla\Filesystem\Exception\FilesystemException

Arguments

file

mixedThe file name or an array of file names

Response

boolTrue on success

invalidateFileCache

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

invalidateFileCache(string file) : void
static

Arguments

file

stringThe path to the file just written to, to flush from opcache

makeSafe

Makes the file name safe to use

makeSafe(string file, array stripChars = ['#^\.#']) : string
static
since

1.0

Arguments

file

stringThe name of the file [not full path]

stripChars

arrayArray of regex (by default will remove any leading periods)

Response

stringThe sanitised string

move

Moves a file

move(string src, string dest, string path = '', bool useStreams = false) : bool
static
since

1.0

throws

\Joomla\Filesystem\Exception\FilesystemException

Arguments

src

stringThe path to the source file

dest

stringThe path to the destination file

path

stringAn optional base path to prefix to the file names

useStreams

boolTrue to use streams

Response

boolTrue on success

stripExt

Strips the last extension off of a file name

stripExt(string file) : string
static
since

1.0

Arguments

file

stringThe file name

Response

stringThe file name without the extension

upload

Moves an uploaded file to a destination folder

upload(string src, string dest, bool useStreams = false) : bool
static
since

1.0

throws

\Joomla\Filesystem\Exception\FilesystemException

Arguments

src

stringThe name of the php (temporary) uploaded file

dest

stringThe path (including filename) to move the uploaded file to

useStreams

boolTrue to use streams

Response

boolTrue on success

write

Write contents to a file

write(string file, string &buffer, bool useStreams = false, bool appendToFile = false) : bool
static
since

1.0

Arguments

file

stringThe full file path

buffer

stringThe buffer to write

useStreams

boolUse streams

appendToFile

boolAppend to the file and not overwrite it.

Response

boolTrue on success